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.
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.
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.
See the following link for more info on Environment variables
http://www.debian.org/doc/manuals/debian-tutorial/ch-shell.html
1. I had to make backup_script executable before the cron job would run. You may also want to prevent other users from having read access the file since it stores a password. The following command will accomplish both:
chmod 700 backup_script
2. If you want the database backup to be compressed, you can use the following command (or the bzip equivalent):
mysqldump -u dbusername -pdbpassword db_name | gzip -c > db_name.sql.gz
Can we add steps on how to do this, since it is different from upgrading from gooseberry to hayes.
Thanks Intnenet Scooter and mhenry07 for the extra pointers! (-:
edited 04:33, 7 Nov 2007
* 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
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.
# 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
if any body can help me a really apreciate it.
thanks
Thanks