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.

For Linux users, explanations on built-in scripts are available here: http://www.mindtouch.com/index.php?t...g_up_MindTouch .

Backing up your database

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.

Backing up your attachments

cd /path/to/wiki/;
tar cvzpf attachments.tar.gz attachments

Backup config files

Copy the following files: 

  • /var/www/deki-hayes/LocalSettings.php
  • /var/www/deki-hayes/AdminSettings.php (if it exists - typically on older Deki Wikis)
  • /etc/dekiwiki/mindtouch.deki.startup.xml

Restoring your database

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.

Restoring your attachments

cd /path/to/wiki/;
tar xvzpf attachments.tar.gz

Using Crontab for automated backups

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. 

Backup with SSH / rsync

A shell script similar to this (change the hosts and passwords) will back up your database to a remote server. Note that you need to set up passwordless SSH keys for this to work.

#!/bin/bash

DATE=`date --iso`
DUMPFILE='wiki-mysql-dump-'$DATE'.sql'
HOST='backup.example.com'
DATAPATH='/backup/wiki-backup/database'

mysqldump --u root -pXDBXPASSWORDX wikidb > $DUMPFILE

gzip $DUMPFILE

scp $DUMPFILE'.gz' wiki-backup@$HOST:$DATAPATH

rm $DUMPFILE'.gz'

To copy the attachments using rsync to the same server, use a script similar to this:

#!/bin/bash

rsync -ace ssh /var/www/dekiwiki/attachments backup.example.com:/backup/wiki-
backup/attachments/

Run each of these scripts as a cron job from a dedicated 'wiki-backup' user on the wiki server, with a similar user on the backup server.

Tag page
Viewing 15 of 21 comments: view all
internetscooter.. I use the vm deki-hayes but $HOME did not work.
Posted 04:34, 7 Nov 2007
Petrus4, another way to check $HOME is by typing "echo $HOME". Ours is set to /root rather than /home.
Posted 04:26, 8 Nov 2007
darace on the DekiWiki forums provided this list of steps that he had to use to restore his wiki:

* download and start a new virtual machine
* go through the initial setup in your browser
* make sure you have a way of accessing the file system of the virtual machine (howto here (http://wiki.opengarden.org/Deki_Wiki/FAQ/Configuration/How_do_I...Access_Deki_Wiki_through_windows_Explorer%3f))
* go to the directory /var/www/deki-hayes and copy the file LocalSettings.php to your workstation
* open the mysql dump file with an editor and look for the phrase *'security/api-key'*. Replace the key found here (from the previous wiki installation) with the one you can find in the current */var/www/LocalSettings.php* file (listed as *$wgDekiApiKey*)
* log on as root to the console (default password = 'password')
* delete the current (empty) wiki database which is called wikidb with the following command: *mysql -uroot -ppassword -e "drop database wikidb"*
* create a new empty database: *mysql -uroot -ppassword -e "create database wikidb"*
* import the dump into the new database: *mysql -uroot -ppassword wikidb < wikidb.sql*
* change directory by typing the command: *cd /var/www/deki-hayes/maintenance*
* run *php update-db.php* in order to restore the stored procedures needed by deki wiki

R0yk3 provided another backup method that uses a backup agent running on the VMware Server host. You
back up a virtual machine by suspending and resuming it with batch files containing
vmware-cmd commands. Suspending a virtual machine puts it in a state in which the
host backup software can gain exclusive access to the virtual machine files to complete
its task.
To backup a virtual machine directory using a backup agent
1 Add the following line to your suspend batch file:
vmware-cmd <path_to_config>\<config>.vmx suspend
2 Once the virtual machine is suspended, you can safely back up this virtual
machineʹs directory using the backup agent installed on the VMware Server host.
3 After the backup job completes, run a resume batch job to restart the virtual
machine.
The batch file should contain the following line:
vmware-cmd <path_to_config>\<config>.vmx start
This command resumes the virtual machine into an active, running state.
! If you want to restore a virtual machine to a server other than the VMware Server
host where it was originally located, shut down the virtual machine. Instead of
using the suspend batch file, use one that powers off the virtual machine.
vmware-cmd <path_to_config>\<config>.vmx stop
! The suspend, stop, and resume commands can be used in pre‐ and post‐job scripts
that are normally available via the backup software being used. Backup software
such as Veritas Backup Exec has the capability to run pre‐ and post‐batch jobs with
scheduled backups. edited 20:33, 14 Nov 2007
Posted 18:29, 14 Nov 2007
Instead of full backup the MySQL data and attachment data, is there any easy way to incremental backup them? A cron job would be even better. Thanks.
Posted 15:34, 16 Nov 2007
When attempting to make a backup of the MySQL db (In the VM distribution), I get the following error:

mysqldump: Got error: 1044: Access denied for user 'wikiuser'@'localhost' to database 'wikidb' when using LOCK TABLES

Apparently the generic 'wikiuser' in the VM-provided doesn't have permission to lock the tables for dumping. I also don't know the 'root' password to the MySQL instance in the VM, and 'wikiuser' doesn't have GRANT permission, so I can't fix the permissions.

Any suggestions would be welcome.
Posted 01:51, 5 Jan 2008
I have followed the above instructions for a crontab to backup my database and attachments to: /mnt/hgfs/BackupWiki . I'm trying to understand, is that a folder that exists outside of my vmware machine so that when I write my backups to that location, I'm actually storing them on a different machine (which is what I want). Or do I have to physically move/copy them from /mnt/hgfs/BackupWiki to another machine to have them stored on a different box?
Posted 23:55, 16 Jan 2008
@bighorton: on the VM, the root passwords can be located in /var/www/deki-hayes/AdminSettings.php
Posted 00:21, 17 Jan 2008
In regards to the size of a backup. Has anyone tried this on a large scale? Like say there are a couple million attachments. That's going to take forever and a lot of space. Is there another method for doing this? Can the Wiki handle this type of environment?
Posted 21:14, 25 Jan 2008
#!/bin/bash
# helperscript :)
DB_CATALOG=`cat /etc/dekiwiki/mindtouch.deki.startup.xml |grep '<db-catalog>'|sed 's/.*>\(.*\)<.*/\1/'`
mysqldump -u root -p $DB_CATALOG >$DB_CATALOG.$(date +'%Y%m%d').sql
Posted 13:01, 14 Mar 2008
hi everyone, i am learning how to use deki-wiki and i need some help, i did a back up of my database using mysqldump -u root -p wikidb >res.sql, but when i tried to restore it i had a sintax error in mysql, i did this: mysql -u root -p wikidb < res.sql; you have a error with sql sintax, check your manual that correspond to the version of your mysql....

if any body can help me a really apreciate it.

thanks
Posted 16:11, 18 Mar 2008
Hi everyone, Iam also just learning how to use deki-wiki. Can someone give me instruction on how to back up the deki wiki. Do i need a extrenal drive or can I back up on the same computer where i have instaulled the deki wiki.

Thanks
Posted 20:37, 27 Mar 2008
hi,garbrie184. when restore backup database, you first go into "mysql command line" mode and write "use 'wiki';source 'your path\res.sql'".
Posted 02:49, 17 Apr 2008
I was using the "How do I...Access Deki Wiki through windows Explorer?" method to enable me to edit files in windows using a standard windows text editor. This works fine with php files but as a linux newbie I didn't realise that scripts have to be in UNIX format. Fortunately I was using "NoteTab Light" which gave me the option of saving the file in UNIX format. The script then worked correctly.
Posted 14:40, 29 Sep 2008
These backup instructions appears to be missing the backup of an essential file to allow for restoration of the backup, at least for Linux. The file that is being missed is /etc/dekiwiki/mindtouch.host.conf

Also, I have noted that there are at least three different sets of backup instructions for Mindtouch - this one, one under the FAQ section - http://developer.mindtouch.com/index.php?title=Deki/FAQ/Configuration/How_do_I...Backup_my_Deki%3F, and also one discussing the use of MindTouch on Amazon EC2 that specifies the use of the built in dataWiki.sh backup script (see http://developer.mindtouch.com/Deki/Installation_and_Upgrade/Using_MindTouch_Deki_on_Amazon_EC2).

We have tested the dataWiki.sh scripted backup process and this works at least for Linux. I would suggest that rather than having these backup and restore instructions in multiple places, that they are combined into a single page that can then be referenced on any other pages that require instructions for backing up and restoring Mindtouch. Otherwise, these different sections are going to get out of date and provide erroneous instructions.
Posted 00:41, 26 May 2009
@btheato thank you for the feedback. We are constantly reviewing the documentation including the backup and restore process. Currently there are 2 ways to backup and restore as you noted: the above manual process and the built in script. The built in script is a fast and easy way to backup and restore between installs of the same version. This was created for the use with EC2 installs, but was also included with our packages to make it easy for server admins to do routine backups. As for the manual instructions, these are provided for the other backup use cases including backing up from an old version and restoring on a newer version. In both of these cases the mindtouch.host.conf file is needed and I will make changes to our current documentation to include this. In the weeks/months to come we will be consolidating our documentaiton to remove redundancies and ensure accuracy of documentation across the board. If you find any documentation that is missing or needs updating please add it to the list here: http://developer.mindtouch.com/User:Coreyg/Documentation_needed I'm actively monitoring this page and will make changes accordingly.
Posted 16:19, 26 May 2009
Viewing 15 of 21 comments: view all
You must login to post a comment.