Help - Search - Members - Calendar
Full Version: Tutorial: cPanel - Automatic MySQL Backups for the Novice
A Small Orange Forums > User-To-User Support > Getting Started
The Newmanium
Greetings all! I wrote this tutorial and I hope it will help you all out.

Note: This tutorial is cross-posted at my "blog".

The ease of which users can create a message board or online community is becoming easier every day. With the help of Fantastico, which is provided with most hosts, a user can create a message board in three clicks. The problem with this become apparent when the word “backup” comes into play.

Those who are not tech savvy tend to believe that their hosting company will take care of backing up their information. While this may be true, the hosts explicitly state they can not guarantee the quality, or lack of corruption, of said backups.

For those with cPanel, I have an easy + automatic solution.

Navigate to “Cron Jobs” and choose the “Advanced (Unix Style)” layout.

You will be given the following options:

Minute: 0
Hour: 3 // This represents 3AM, which is usually an inactive time
Day: * // Means the script is run every day of the week
Month: * // Means the script is run every month of the year
Weekday: 0 // Means the script is run every sunday
Command: mysqldump –opt -Q -u dbusername –password=dbpassword dbname > /pathto/backups/sunday.sql

In the command prompt, you will need to replace the red variables that correspond to your information. Remember, if you are on shared hosting, your dbname and dbusername probably have a prefix.

Also note that it is asking for the backup path, not the backup URL.

After doing the first script repeat it six times but change the weekday from 0 to 1 (then 1 to 2, until you reach 6) and the filename from sunday to monday (then monday to tuesday, until you reach saturday).

After you have completed the above step, you are finished!!!

With this method, you are backing up everyday, BUT you have copies from the past seven days instead of rewriting the same copy everyday. This is advantageous because you may want to restore to a certain point or your only backup may have been corrupted.
z3rb
Great tut man!

/me uses
eisa01
Nice, I think I'll set up something similar, but to an external server. Then if ASO's server really crashes, I'll still have a backup available.
The Newmanium
You can use this if you have a separate FTP server to up them to...
jaseone
Use just a daily job with:

CODE
mysqldump –opt -Q -u dbusername –password=dbpassword dbname > /pathto/backups/`date +%A`.sql


or get real fancy and gzip it as well:

CODE
mysqldump -opt -Q -uusername -ppassword db_name | gzip > /path/to/backups/`date +%A`.gz


Note: I haven't actually tested those but they should work...

EDIT: Made a small change to the first example, BASH scripting is fun. biggrin.gif
z3rb
i love you jasone smile.gif
nezermundy
If you replace the file path with an email address will that work?
jaseone
An email one liner is coming up, I'll test that one first as well before posting it. wink.gif
jaseone
Okay first you need to make sure mutt is installed on your server (just try mutt from a shell and if it isn't raise a support ticket to see if ASO will install it for you) then the command is:

CODE
mysqldump -Q -uuser_name -ppassword db_name | gzip > /path/to/backup/`date +%A`.gz && mutt -s "`date +%A`'s backup" -a /path/to/backup/`date +%A`.gz someone@nowhere.com < /dev/null


That will pipe the output of the mysqldump to gzip, gzipping it (note the gzipped file doesn't have a .sql extension, I'll see if I can add that but it is no biggie) and then attach it to an email with a subject like Monday's backup and send the email to the address specified with a blank body.

Note that there is no space after -u & -p for the username and password.

It isn't truly a one liner as I cheated and used && to treat the mutt part as a separate command, it is possible you could do it all in one command but I can't be bothered working out if you can.
Max
Here's a script I wrote that backs up all my databases, the entire home directory, archives everything, and uploads it to my home server. Feel free to use it (create a new directory in your root named backup, and place this script there):

CODE
#!/bin/bash

cd /home/mydomain/backup

# Database Settings
DATABASES='database1 database2 database3'
DATABASE_PREFIX='mysite_'
DATABASE_USER='mysite_username'
DATABASE_PASS='mypassword'

# FTP Settings
FTP_HOST='myserver.com'
FTP_USER='backup_user'
FTP_PASS='backup_password'
FTP_PATH='/'

# Backup entire home directory
TIMESTAMP=`date +%F-%H-%M`
tar -czf ${TIMESTAMP}_files.tar.gz --exclude ../backup --exclude ../www ../

# Backup databases
for database in ${DATABASES}
do
    mysqldump -u ${DATABASE_USER} --password=${DATABASE_PASS} --opt -Q ${DATABASE_PREFIX}${database} > ${TIMESTAMP}_${database}.sql && gzip --best ${TIMESTAMP}_${database}.sql
done

# Combine the backup
tar -cf ${TIMESTAMP}.tar *.gz

# Remove all by the final tar
rm *.gz

# Upload the backup
ftp -i -n ${FTP_HOST} << EOF
user ${FTP_USER} ${FTP_PASS}

binary
passive
cd ${FTP_PATH}
put ${TIMESTAMP}.tar

quit
EOF

# Remove the remaining tar
rm *.tar

exit 0


You may also want to remove that part that archives the entire home directory, if all you need are just the databases. Right now I'm trying to figure out why the damn thing will not connect using passive mode, so that's why the FTP is using active in there. If you want to use passive, remove that word from the ftp command.
eisa01
Nice script, might try to modify that. Zip compression is much more effective than gzip though. I tried gzip --best on a .sql file, and it came out over 30mb big. With zip compression, the file was only 3.5 mb big.

Edit: Maybe we should get something like TextSnippets, that the users of TextDrive has?
Max
Just tried that with my site (all files plus databases). The tar.gz came out to 7520KB, a RAR with best compression to 7600KB, a ZIP with best compression to 7745KB.

Certainly not representative of the algorithms in general, but so far gz isn't too bad smile.gif
yann
I'm tryin to use this script but I get the following error:

mysqldump: Got error: 1045: Access denied for user 'minimald'@'localhost' (using password: NO) when trying to connect

I'm using the following line for the cron job (I just copied it from here, no idea what it means, so ... I need help wink.gif:

mysqldump –opt -Q -u user –password=pass minimald_DBNAME > /home/minimald/backup_folder/sat.sql

Any idea? Thanks!
ukdmbfan
The error message gives most of it away - it's telling you you're not supplying the program with a password, which means either you're not or your command syntax is incorrect.

From a quick look at what you've posted I'd say that -password=pass is incorrect. I would have thought it either has to be:\

-ppassword

or

--password=password

Using either of these should work.
thrive
Thanks for the great tutorial. ASO already has a wiki, which I would think is a great place to put it.
yann
ok - got it to work... for some reason, when I copy pasted the code above, I got m-dashes instead of "--" front of "opt" and password... I had to look at the mysqldump help page to figure out the right syntax...

Thanks for pointing me in the right direction.

ater looking into the code from Jason to have the date within the file name, it didn't work at first but I changed it to the following and it's all good now:

[codebox]date=`date -I`; mysqldump --opt -Q -uusername -ppassword db_name | gzip > /home/user/path/to/backup/backup_name_$date.gz[/codebox]
Cary
Hi, I'm a total noob when it comes to this kind of stuff. I got my Cron jobs set up, but I'm getting the following error:

>> /bin/sh: /backups/saturday.sql: No such file or directory

Where exactly in my account do I need to create the /backups folder? The path I entered in my Cron job was just: /backups/saturday.sql

Thanks smile.gif

thrive
Also pretty much a noob.. but

I think it is a permissions error. Try changing the permissions on the folder.

Another thing to try is creating a blank file called saturday.sql and see if it works after that. (Just open notepad and press save and type in the filename)
Ghoul
The path is set incorrectly. Whenever you have a path that begins with a forward slash, you're telling Linux that it is an absolute path, not a relative path. It's kind of like the difference between C:\Documents and Settings\Username\Backup\ and C:\Backup\.

Try this path instead: ~/backups/saturday.sql

A tilde in front of a path means to use the users home directory, which is usually /home/username or /home2/username.
mrsmac1974
QUOTE(Ghoul @ Feb 17 2007, 6:08 PM) [snapback]61417[/snapback]
The path is set incorrectly. Whenever you have a path that begins with a forward slash, you're telling Linux that it is an absolute path, not a relative path. It's kind of like the difference between C:\Documents and Settings\Username\Backup\ and C:\Backup\.

Try this path instead: ~/backups/saturday.sql

A tilde in front of a path means to use the users home directory, which is usually /home/username or /home2/username.

Clarification, please, I'm way lost here. For reference, I'm using the script posted in the first post of this thread.

I created the backups folder here: public_html/backups

My forum is: public_html/forums

So would the correct path be: public_html/backups

or do I need to tilde the path?

Also is there a way to run that script early to make sure it will function, or do I just to see if I receive an email telling me it ran?
Ghoul
Try:
CODE
~/public_html/backups

Or...
CODE
/home/USERNAME/public_html/backups

In some cases it might be home2 or home3 (depending on if your account is on an extra hard drive. Username is your CPanel login name.

I don't recommend storing your backups in a publicly accessible directory like you're doing, especially one as easily guessed as "backups". tongue.gif

As for running the script manually, if you have shell access then you can.
mrsmac1974
Thanks for the info. I'll give it a try.
Samir M. Nassar
In order to make this work I had to use: (Note the backslash)

CODE
tar -czf /home/USERNAME/backups/`date +\%F`.tar.gz /home/USERNAME/public_html


Then I used the following for my MySQL backup:

CODE
mysqldump -opt -Q -uMYSQLUSER -pMYSQLPASSWD MYSQLDB | gzip > /home/USERNAME/backups/logs/`date +\%F`.gz
PeterT
My approach for backups is the following script

CODE
#!/bin/sh

# Database Settings
DATABASES='list_of_all_mysql_dbs'
DATABASE_PREFIX='xxx_'
DATABASE_USER='xxx_backup'
DATABASE_PASS='some_password'

# Backup site settings
FTP_SITE='ftp.xxx.yyy'
FTP_USER='xxxx'
FTP_PASS='xxxxx'

echo `date` Backup processing started

if [[ ! -e ~/backup ]]; then
    echo
    echo `date` Backup destination does not exist. Creating it
    mkdir ~/backup
elif [[ ! -d ~/backup ]]; then
    echo
    echo `date` Backup destination exists \; however it is not a directory
    echo `date` Exiting now
    exit 1
fi

cd ~/backup

# Backup entire home directory
TIMESTAMP=`date +%F-%H-%M`
echo
echo `date` Backing up Web root directory
tar -czf ${TIMESTAMP}_files.tar.gz ../public_html

# Backup databases
for database in ${DATABASES}
do
    echo
    echo `date` Dumping database: ${DATABASE_PREFIX}${database}
    mysqldump -u ${DATABASE_USER} --password=${DATABASE_PASS} --opt -Q ${DATABASE_PREFIX}${database} > ${TIMESTAMP}_${database}.sql && gzip --best ${TIMESTAMP}_${database}.sql
done

# Combine the backup
echo
echo `date` Creating tar file: ${TIMESTAMP}.tar
tar -cf ${TIMESTAMP}.tar ${TIMESTAMP}*.gz

# Remove the original files
echo
echo `date` Removing input files
rm -v ${TIMESTAMP}*.gz

# Removing old backups
echo
echo `date` Removing old backups
OLD_FILES=`find . -mtime +7 -print`
for filename in ${OLD_FILES}; do
    echo `date` Removing ${filename}
    rm ${filename}
done

# Build FTP command's
echo
echo `date` Building FTP script
TMP_FILE='my_cmds.$($}'
echo user ${FTP_USER} ${FTP_PASS} > ${TMP_FILE}
echo binary >> ${TMP_FILE}
echo passive >> ${TMP_FILE}
echo put ${TIMESTAMP}.tar >> ${TMP_FILE}
for filename in ${OLD_FILES}; do
    echo delete ${filename} >> ${TMP_FILE}
done
echo quit >> ${TMP_FILE}

# Sending backup offsite
echo
echo `date` Sending backups offsite
ftp -i -n ${FTP_SITE} < ${TMP_FILE}

# Removing command file
echo
echo `date` Removing FTP command file
rm ${TMP_FILE}

# all done
echo
echo `date` Backup processing completed

exit 0


I have ensured that I have added one id "DATABASE_USER" to all MySQL db's and ensure that it has read access to all.

The script attempts to ensure that a destination for the backups exist, then dumps the web root, all of the MySQL databases. TARSs all the bits up togerher, and then ships the resulkting backup over to another web host. At the same time, it tries to manage ther space usage on both sites by dropping all backups older than 7 days on this host, and also dropping the same backups on the FTP site.

Peter
mattjabs
QUOTE(PeterT @ Mar 29 2007, 4:01 PM) [snapback]62825[/snapback]
My approach for backups is the following script

CODE
#!/bin/sh

# Database Settings
DATABASES='list_of_all_mysql_dbs'
DATABASE_PREFIX='xxx_'
DATABASE_USER='xxx_backup'
DATABASE_PASS='some_password'

# Backup site settings
FTP_SITE='ftp.xxx.yyy'
FTP_USER='xxxx'
FTP_PASS='xxxxx'

echo `date` Backup processing started

if [[ ! -e ~/backup ]]; then
    echo
    echo `date` Backup destination does not exist. Creating it
    mkdir ~/backup
elif [[ ! -d ~/backup ]]; then
    echo
    echo `date` Backup destination exists \; however it is not a directory
    echo `date` Exiting now
    exit 1
fi

cd ~/backup

# Backup entire home directory
TIMESTAMP=`date +%F-%H-%M`
echo
echo `date` Backing up Web root directory
tar -czf ${TIMESTAMP}_files.tar.gz ../public_html

# Backup databases
for database in ${DATABASES}
do
    echo
    echo `date` Dumping database: ${DATABASE_PREFIX}${database}
    mysqldump -u ${DATABASE_USER} --password=${DATABASE_PASS} --opt -Q ${DATABASE_PREFIX}${database} > ${TIMESTAMP}_${database}.sql && gzip --best ${TIMESTAMP}_${database}.sql
done

# Combine the backup
echo
echo `date` Creating tar file: ${TIMESTAMP}.tar
tar -cf ${TIMESTAMP}.tar ${TIMESTAMP}*.gz

# Remove the original files
echo
echo `date` Removing input files
rm -v ${TIMESTAMP}*.gz

# Removing old backups
echo
echo `date` Removing old backups
OLD_FILES=`find . -mtime +7 -print`
for filename in ${OLD_FILES}; do
    echo `date` Removing ${filename}
    rm ${filename}
done

# Build FTP command's
echo
echo `date` Building FTP script
TMP_FILE='my_cmds.$($}'
echo user ${FTP_USER} ${FTP_PASS} > ${TMP_FILE}
echo binary >> ${TMP_FILE}
echo passive >> ${TMP_FILE}
echo put ${TIMESTAMP}.tar >> ${TMP_FILE}
for filename in ${OLD_FILES}; do
    echo delete ${filename} >> ${TMP_FILE}
done
echo quit >> ${TMP_FILE}

# Sending backup offsite
echo
echo `date` Sending backups offsite
ftp -i -n ${FTP_SITE} < ${TMP_FILE}

# Removing command file
echo
echo `date` Removing FTP command file
rm ${TMP_FILE}

# all done
echo
echo `date` Backup processing completed

exit 0


I have ensured that I have added one id "DATABASE_USER" to all MySQL db's and ensure that it has read access to all.

The script attempts to ensure that a destination for the backups exist, then dumps the web root, all of the MySQL databases. TARSs all the bits up togerher, and then ships the resulkting backup over to another web host. At the same time, it tries to manage ther space usage on both sites by dropping all backups older than 7 days on this host, and also dropping the same backups on the FTP site.

Peter



I tried using this script but I receive this email from the cron daemon:

Wed May 2 12:30:01 PDT 2007 Backup processing started
/home/issice5/backup/backup.sh: line 18: syntax error near unexpected token `elif'
/home/issice5/backup/backup.sh: line 18: `elif [[ ! -d ~/backup ]]; then '


I already have the folder created, so can I just delete this section of code?

if [[ ! -e ~/backup ]]; then
echo
echo `date` Backup destination does not exist. Creating it
mkdir ~/backup
elif [[ ! -d ~/backup ]]; then
echo
echo `date` Backup destination exists \; however it is not a directory
echo `date` Exiting now
exit 1
fi

Thanks so much for your help.

I tried taking out that code, but now I'm getting these errors:

Wed May 2 12:40:01 PDT 2007 Backup processing started
/home/issice5/backup/backup.sh: line 14: cd: /home/issice5/backup
: No such file or directory
/home/issice5/backup/backup.sh: line 18: echo
: command not found
Wed May 2 12:40:01 PDT 2007 Backing up Web root directory
tar: Removing leading `../' from member names
tar: ../public_html\r: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
/home/issice5/backup/backup.sh: line 24: syntax error near unexpected token `do '
/home/issice5/backup/backup.sh: line 24: `do '

Can anyone help? I've been trying to get this working all day. Thanks.
Karen
QUOTE(The Newmanium @ Jan 2 2006, 4:13 AM) [snapback]38543[/snapback]
Minute: 0
Hour: 3 // This represents 3AM, which is usually an inactive time
Day: * // Means the script is run every day of the week
Month: * // Means the script is run every month of the year
Weekday: 0 // Means the script is run every sunday
Command: mysqldump –opt -Q -u dbusername –password=dbpassword dbname > /pathto/backups/sunday.sql


Sorry for what's probably a complete stupido question but could someone explain what the dbusername and dbpassword are?

Thanks
jednorozec
QUOTE(Karen @ May 18 2007, 7:11 AM) [snapback]64390[/snapback]
Sorry for what's probably a complete stupido question but could someone explain what the dbusername and dbpassword are?

Thanks

The stupidest question is the one that never gets asked leaving the person in ignorance. You don't need to use a special dbusername and dbpassword. cPanel creates databases using your cPanel username and password and those will work just fine.
Karen
Thanks for the help.

I think I've done it, how do I check if it's working?

Thanks...
jednorozec
QUOTE(Karen @ May 26 2007, 8:41 AM) [snapback]64649[/snapback]
Thanks for the help.

I think I've done it, how do I check if it's working?

Thanks...

See if the file is there and if it has reasonable looking data in it.
Here's the script that I'm using
CODE
#!/bin/sh
date=`date +%y%j%H%M%S`
mysqldump -uuser -ppassword user_$1 | gzip -c > /home/user/mysql/$date.$1.sql.bz2

I called it backupmysql and you invoke it as 'backupmysql database' where database doen't need the leading user_. This allows me to set up a different cron interval for each database and it minimizes the typing that I have to do.
Karen
Must admit I'm slightly confused...

I created a folder called 'backup' in File Manager

then used this in the cron jobs:

mysqldump –opt -Q -u username –password=password databasename> /home/username/backup/sunday.sql

This is what I found afterwards in the backup file:

MySQL dump 10.9
--
-- Host: localhost Database: –opt
-- ------------------------------------------------------
-- Server version 4.1.21-standard

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
jednorozec
What are you confused about? That file looks fine as long as it goes on for quite a ways after what you posted.
Karen
QUOTE(jednorozec @ May 29 2007, 1:28 AM) [snapback]64713[/snapback]
What are you confused about? That file looks fine as long as it goes on for quite a ways after what you posted.



That's all there is in there, I was trying to back up vbulletin.
jednorozec
It should be --opt not -opt but you can leave it out as it's the default. You can also leave out the -Q. It should be --password or -p. The number of - signs makes a big difference.
Mark_r
I have the exact script from page 1 of this thread saved (in textwrangler), named as comp.sh and it sits above public_ html

I get this every time:
CODE
/home/name/complete.sh: line 1: #!/bin: No such file or directory
tar: Removing leading `..' from member names
tar: ..: Cannot open: Permission denied
tar: Error exit delayed from previous errors
Passive mode off.

I have tried
#!/bin
#!/bin/sh
#!/bin/bash

and I get the same error exactly.
I understand that later errors are all about something else but until it gets going I can work on those.
The script is on analucia.

Any help is apppreciated.
jednorozec
Here's the script that I use for MySQL backups
CODE
#!/bin/sh
# change this to your cPanel user name
user="username"
# change this to your cPanel password
password="password"
# change the date string if you want
date=`date +%y%j%H%M%S`
mysqldump -u$user -p$password "$user"_$1 | gzip -c > ~/mysql/$1.$date.sql.gz

I've called it backupmysql and it is invoked as "backupmysql database" where database is the database name without the leading username_. Doing it this way allows you to use a different backup schedule for each of your databases. Make sure that you do a chmod 700 on the script and create the backup directory.
Mark_r
Not sure if the above is to me?

I have all my db backups setup and they go into a gmail account just for that.
What I'm after is something that will backup /home and ftp that into another account.
chessmani
Does anyone know a way to pipe the debug log of the mysqldump into mutt so that you receive the backup logs at your mail?
dasy
Anybody creating a bash file on widows and uploading it, watch out because you'll need to format carriage return in unix style (LF), not DOS (CR-LF).
Dr Macinyasha
Hey guys, I'm getting this when I try to run any of the scripts:
CODE
theviper@server1 [~]# sh backups
: command not found
: command not found
: command not found
Fri Jan 2 01:14:44 EST 2009 Backup processing started
: command not found
backups: line 20: syntax error near unexpected token `elif'
'ackups: line 20: `elif [[ ! -d ~/backup ]]; then
warlord69
i would personally use max's backing up your online server to your online server smile.gif doesn't seem like much of a backup :0 unless you have time to download copys all the time.
danlodola
Hello All,

I'm new here, having some difficulties getting my bash script to run and hope someone may help me out please!

My script looks something like this:

CODE
#!/bin/sh
USERNAME="***"
PASSWORD="***"
SERVER="***"

# login to remote server
ftp -n $SERVER <<EOF
user $USERNAME $PASSWORD
mput $SOM_FILE/*.tar.gz
quit


I've tried with #!/bin, #!/bin/bash & #!/bin/sh.

Q1: where do I need to put my script file? Any particular place?

Q2: when script runs I get the following error message: "/bin/sh: /SOME_PATH/test.sh: Permission denied". Am I doing something wrong? I get the impression my script isn't even being run...

Thanks in advance for your help.

Daniele
jednorozec
Did you set execute permission on your script?
IBBoard
1) No, the shell script should be able to run from anywhere. It would be advisable to keep it outside your public_html or www directory, though, as people may be able to find it and download your database username/password.

2) As jednorozec said, have you added Execute permissions to the script (it should be something like 755 or rwxr-xr-x)? One of Linux/Unix's layers of security is that to run things you have to make them executable.
danlodola
Thanks a bunch for your help.

I've placed my script (+ all backup files) in a folder at root level.

I've sorted my permissions, and the script is now running.

Now I'm getting this error message "ftp: connect: Connection timed out" each time the script runs, and nothing is being written to the distant server.

This is my code (which just for testing, so nothing too fancy...). I switched from put to mput as with mput I kept on getting even more error messages.

CODE
#!/bin/sh
USERNAME="???"
PASSWORD="???"
SERVER="???"

ftp -n $SERVER <<EOF
user $USERNAME $PASSWORD
put ~/molokai/test.txt
quit


I tested the code from a terminal on my desktop machine, and it works fine from there. It's just from the ASO server it seems to through a wobbly...

Any ideas? Your continued support is MUCH appreciated wink.gif

Best

Daniele
danlodola
Dear All,

I've managed to set up my automated transfer.My questions don't require any more answers.

Thanks a bunch for your help.

DL
IBBoard
Just in case anyone else encounters the same problem, what was the solution? I know how frustrating it can be to go "Ahah, I've found the solution" before reading through and going "oh, no, I've not - they just said 'I've fixed it now'" smile.gif
danlodola
QUOTE (IBBoard @ Mar 3 2009, 2:48 PM) *
Just in case anyone else encounters the same problem, what was the solution? I know how frustrating it can be to go "Ahah, I've found the solution" before reading through and going "oh, no, I've not - they just said 'I've fixed it now'" smile.gif


OK, here goes, this is what I did.

1. I set up public key authentication between my ASO server and the other server I backup my data to.
2. I created the following simple script:

CODE
#!/bin/sh
DATE=` date +%A  | tr "[:upper:]" "[:lower:]" `


mysqldump --opt -Q -u DATABASE_USER --password=DATABASE_PASS DATABASE  | gzip > ~/BACKUP_FOLDER/$DATE.sql.gz

scp ~/BACKUP_FOLDER/$DATE.sql.gz SOME_DISTANT_SERVER:~/DISTANT_BACKUP_FOLDER


3. I set a cron job to run the script every day at 1 minute past midnite.

Voilà!

Any ideas to improve the process?

Best

DL
IBBoard
Just a note for anyone trying this on a VPS account who doesn't have Mutt installed: It is possible to do it with "mail" (mailx) but only if you have a new enough version. I've got a developer account and so I've stripped it down and don't want exim (one of the requirements for Mutt) as I'm running a postfix/dovecot combo. Instead I grabbed the SRPM for mail v12 from Fedora 10, rebuild it and it now has a "-a" option so you can use mail to attach files to emails.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.