Published 2002-05-03 21:48:00

Well what a nightmare - (it was only one luckly) - I had this horrible dream about someone nicking (thief for non brits), my beloved server, with this site on it.  Well, it was a bit of a kick in the backside to finish off the small project of remote backing up this machine. Below is the backup script, and some info on how to set up ssh2's authentication keys thanks to Paul Keck's HOWTO: set up ssh keys.

The Backup script

In all it's lovely glory - this file is stuck in the /etc/cron.daily, and makes daily backups of my major databases (including midgard) , the midgard blob directory and the bits and bobs in my /var/www web directory. The only other stuff preserving is in the phpmole cvs, which I have few copies of anyway...


#!/bin/sh
#// dumping section  of backup.. # DATE = 2001_jan_monday   DATEM = 2001_jan #rotated files
DATE=`/bin/date +%Y_%B_%A`
DATEM=`/bin/date +%Y_%B`

# dump databases! - Midgard,

rm /var/backup/midgard_$DATE.sql.gz
/usr/bin/mysqldump --opt -uroot -pxxxxxxx midgard > /var/backup/midgard_$DATE.sql
/bin/gzip /var/backup/midgard_$DATE.sql

# Sitegroup databases
rm /var/backup/mgd_6b080197635b37e72ff2c257abf0b957_$DATE.sql.gz
/usr/bin/mysqldump --opt -uroot -pxxxxxxx mgd_6b080197635b37e72ff2c257abf0b957 > /var/backup/mgd_6b080197635b37e72ff2c257abf0b957_$DATE.sql
/bin/gzip /var/backup/mgd_6b080197635b37e72ff2c257abf0b957_$DATE.sql

rm /var/backup/mgd_e734103d46be96da3213acd005cf4bf1_$DATE.sql.gz
/usr/bin/mysqldump --opt -uroot -pxxxxxxx mgd_e734103d46be96da3213acd005cf4bf1 > /var/backup/mgd_e734103d46be96da3213acd005cf4bf1_$DATE.sql
/bin/gzip /var/backup/mgd_e734103d46be96da3213acd005cf4bf1_$DATE.sql

#mysql's database  - so all the passwords work!
rm /var/backup/mysql_$DATE.sql.gz
/usr/bin/mysqldump --opt -uroot -pxxxxxxx mysql > /var/backup/mysql_$DATE.sql
/bin/gzip /var/backup/mysql_$DATE.sql


# tar up web data (fimages and blobs etc.)
/bin/tar cvzf /var/backup/var_www_$DATEM.tgz /var/www/


#// transfer it somewhere!!!

/usr/bin/rsync -vvvv -a -e /usr/bin/ssh  /var/backup/* alan@mybackupserver.com:/home/alan/akbkhome_backup/


The SSH2 setup from Paul Keck's HOWTO: set up ssh keys. used to be here..

Mentioned By:
google.com : php mysqldump (126 referals)
google.com : april (68 referals)
google.com : mysqldump php (66 referals)
google.com : /usr/bin/mysqldump (49 referals)
google.com : december (34 referals)
google.com : mysqldump gzip (29 referals)
google.com : php ssh2 (17 referals)
google.com : automated mysqldump (16 referals)
google.com : mysqldump date (16 referals)
google.com : mysqldump with php (13 referals)
google.com : php mysqldump script (12 referals)
google.com : usr/bin/mysqldump (11 referals)
google.com : mysqldump date time (9 referals)
google.com : mysqldump in php (9 referals)
google.com : ssh2 php (8 referals)
google.com : php mysqldump gzip (7 referals)
google.com : mysqldump gzip date (6 referals)
google.com : php mysqldump backup (6 referals)
google.com : /usr/bin/mysqldump -R -c -Q -q (5 referals)
google.com : /usr/bin/mysqldump -u (5 referals)

Add Your Comment

Follow us on