Agon Posted November 17, 2009 Posted November 17, 2009 This is a nice little script if you have a LINUX server and SSH access. SSH to your server. Here's the script. Self explanatory. mysqldump --opt -h 127.0.0.1 -u db_username -pdb_password db_name | gzip -c > gzip_filename.gz mutt -a gzip_filename.gz -s "Subject line of email with $DATESTAMP" [email][email protected][/email] < text_file_with_text_to_send_in_email_body Now FTP the file over and make it executable as in chmod 744 or 644. In the bash shell, you can test it by using the "dot filename" invocation as in # . backup_script.bash No errors? Check your email? Did it work? Create a cron job. And DONE! Enjoy. Quote
a_bertrand Posted November 17, 2009 Posted November 17, 2009 2 things: 1) there will be only one backup, as new one will overwrite old one. I prefer to keep old backups for a while. 2) Doing the gzip directly from the pipe slows downs the mysqldump and therefore takes more time with locked tables. I would suggest to do it in 2 steps. Here is what I do: #!/bin/sh filename=`date '+/[backup_dir]/%d_%m_%Y.sql'` rm -f "$filename.gz" mysqldump -u[user] -p[pass] [dbname] --add-drop-table > $filename gzip $filename Now replace [backup_dir] with your directory where you want the backup files replace the[user] with the DB username replace the [pass] with the DB password replace the [dbname] with the DB name Quote
rulerofzu Posted November 18, 2009 Posted November 18, 2009 If your on a cpanel server there is a free download cp sitesaver. Will save your site and database. I use it to run at midnight automagically to a backup server using timestamps so saves 10 backups and will then remove the oldest before creating the latest backup. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.