Backing up your MindTouch Deki involves three steps: backing up your database, your file attachments, and your config files.
During the evolution of MindTouch Deki certain directory names, file names and locations may have changed. For instance, versions earlier than 1.9.0 used the default path of/var/www/deki-hayes for the Deki installation while versions from and after 1.9.0 use the default path of /var/www/dekiwiki. Note which version of Deki you are using and understand that you may need to modify the instructions given on this page accordingly.
You can do this from command line by issuing the following command:
mysqldump -udbusername -p db_name > db_name.sql
Note: If you have a multi-tenant installation of Deki you have multiple databases and need to backup each database separately.
cd /path/to/wiki/; tar cvzpf attachments.tar.gz attachments
Copy the following files:
mysql -udbusername -p db_name < db_name.sql
Note: If you have a multi-tenant installation of Deki you have multiple databases and need to restore each database separately.
cd /path/to/wiki/; tar xvzpf attachments.tar.gz
The following is an example of automated backups. This assumes that /mnt/hgfs/BackupWiki is available to dump backups to outside the VM image (e.g. a directory on another disk) and the result is 7 daily backups a week tagged by day (e.g. Thu.attachments-backup.tar.gz and Thu.wikidb-backup.sql). (Note: it would be nice for someone to document how to do this via SCP,FTP or rsync for those that don't have mnt/hgfs/BackupWiki configured).
The backup_script
#!/bin/bash today="$(date +%a)" #dump today's database mysqldump -u root -ppassword wikidb > /mnt/hgfs/BackupWiki/$today.wikidb-backup.sql #dump today's attachments cd /var/www/deki-hayes/ tar czf /mnt/hgfs/BackupWiki/$today.attachments-backup.tar.gz attachments
The script above creates files with a name like "Sun.wikidb-backup.sql". i,.e. only the day of the week is prepended to the backup name. You can format the date any way you like. Type man date at the command prompt to see all formatting possibilities (begin with %).
A useful one is
today="$(date + %Y-%m-%d)"
whch results in files like "2008-01-25.wikidb-backup.sql"
Make a cron job ("crontab -e" to create and edit) to run the script automatically.
The script below runs the backup_script daily at 4 am.
# m h dom mon dow command 0 04 * * * sh $PATH_TO_YOUR_SCRIPT/backup_script > /var/tmp/dekiwiki.backup.log 2>&1
NOTE: Alternatives to the sh in the above command are bash, ksh or csh depending upon the shell that you are using. You may also precede the backup_script with a simple ". " (dot) to execute the shell script. In order to execute the backup command without the above sh or equivalent you give backup_script execute permission with the command "chmod 700 backup_script".
The 2>&1 in the above crontab command redirects errors in executing the command to the /var/tmp/dekiwiki.backup.log which you should review for errors which may keep you backup from completing successfully. Always verify that that the crontab backup has run as specified to ensure that you have valid backups of your database and attachments.