I thought it might be a good idea for Aquarionics to be backed up on occasion. All the PHP is saved on my local machine before it’s uploaded here, so the code is fine, but the database hadn’t been backed up since I recreated my local copy of the site, about a month ago, and then about six months before that. This is because I had an automatic backup system on hive.beehost.net before I moved the site to pol’s server.

So now, I have a cronjob and a couple of scripts that do a mysqldump on Afphrid and Aquarionics’ databases every month, compress them and save them, whilst every day I do another mysqldump, diff that against the monthly one, and save that. The entire directory of backups will get downloaded every week by a server on the other side the world. I am not a paranoid person.

Backup.sh

Run monthly.

#!/bin/bash
DATE=$(date +%Y-%m-%d)
WHERE=/home/sites/site3/users/aquarion/backups
mysqldump --password=(PASSWORD) -u aquarion klind | bzip2 -c  > $WHERE/aqcom/$DATE.bz2
if [ -e $WHERE/aqcom/backup.bz2 ]
then
        rm $WHERE/aqcom/backup.bz2
fi
ln -s $WHERE/aqcom/$DATE.bz2 $WHERE/aqcom/backup.bz2

mysqldump --password=(PASSWORD) -u aquarion afphrid | bzip2 -c  > $WHERE/afphrid/$DATE.bz2
if [ -e $WHERE/afphrid/backup.bz2 ]
then
        rm $WHERE/afphrid/backup.bz2
fi
ln -s $WHERE/afphrid/$DATE.bz2 $WHERE/afphrid/backup.bz2

Increment.sh

Daily

#!/bin/bash
DATE=$(date +%Y-%m-%d)
WHERE=/home/sites/site3/users/aquarion/backups

mysqldump --password=(PASSWORD) -u aquarion klind > /tmp/today.txt
bunzip2 -c $WHERE/aqcom/backup.bz2 > /tmp/backup.txt
diff /tmp/backup.txt /tmp/today.txt | bzip2 -c > $WHERE/aqcom/diff.bz2
rm /tmp/backup.txt /tmp/today.txt

mysqldump --password=(PASSWORD) -u aquarion afphrid > /tmp/today.txt
bunzip2 -c $WHERE/afphrid/backup.bz2 > /tmp/backup.txt
diff /tmp/backup.txt /tmp/today.txt | bzip2 -c > $WHERE/afphrid/diff.bz2
rm /tmp/backup.txt /tmp/today.txt