Saturday, February 23, 2008

Automating Restores for Deki Wiki

If you've got your backup script running for Deki Wiki, and stakeholders are busy adding knowledge - it might be time to build a test environment if you haven't already. After the backup of the production server runs, we're restoring the attachments, and .sql file to our test box. There are some obvious benefits of having a test environment, including...

  1. We have a tested and automated restore procedure that we know works because it happens every day
  2. A box we can test stuff without having to worry about breaking a production box
All you need to do is build out your test box following the same procedures as your production box, then modify your backup script to become a restore script like so... and then schedule the script to run as a cron job.


#!/bin/bash
today="$(date +%a)"

#mount Windows Share
sudo -u root -p password smbmount //server/share /mnt/subdir -o username=user,password=password,rw

#copy down Today's database and attachments
cp /mnt/share/$today.wikidb-backup.sql /home/user/tmprestore
cp /mnt/share/$today.attachments-backup.tar.gz /home/user/tmprestore

#restore Today's database and attachments
cd /home/user/tmprestore
sudo mysql -uroot -ppassword wikidb < $today.wikidb-backup.sql cd /var/www/deki-hayes sudo tar xvzpf /home/user/tmprestore/$today.attachments-backup.tar.gz

2 comments:

Aaron Fulkerson said...

Great! As an additional resource to your readers there is the Deki Wiki FAQ section: http://wiki.opengarden.org/Deki_Wiki/FAQ this article might provide additional info: http://wiki.opengarden.org/Deki_Wiki/User_Manual/Backing_up_your_Deki_Wiki and perhaps could be enriched with your post. :-) Feel free to edit/add info. Thanks for helping on docs and for help spreading the word.

Nick said...

Thanks for the comment and the link! For what it’s worth, I’ve already have contributed to the FAQ, and plan to continue doing so!