Monday, February 04, 2008

Getting daily backups running in Deki Wiki

The backup and restore process for Deki Wiki is pretty easy. No backup agents, no fights, just a short script and a tested procedure.

Dump your database to a .sql file, archive the attachments, put it in a bash script, and schedule it via the root Crontab (sudo crontab -e).

The script linked above is the 95% solution. The only thing you really need to do is have a share on another box somewhere mounted in the /mnt directory. So create a subdirectory “/mnt/backup”, and then use smbmount to mount the new share off of that subdirectory. Just make sure that the credentials you specify with smbmount exist on the target box. Something like this will work in a pinch...

today="$(date +%a)"

#mount Windows Share
smbmount //windowsbox/apps /mnt/backup -o username=username,password=password,rw

#dump today's database
mysqldump -uroot -psqlrootpass wikidb > /mnt/backup/wiki/$today.wikidb-backup.sql

#dump today's attachments
cd /opt/deki-hayes/
tar czf /mnt/backup/wiki/$today.attachments-backup.tar.gz attachments

#Log the job status
echo "Nighly Backup Successful: $(date)" >> /var/log/dekiwikibackup.log

No comments: