Manually backup a wiki

From Organic Design wiki
Procedure.svg Manually backup a wiki
Organic Design procedure

There is a backup script you can run called /var/www/backup.pl which currently backs up and compresses all the mysql databases for all wikis into one compressed file and names them all-yyyy-mm-dd.sql.7z. This will soon be updated to allow a parameter to specify a specific database and optional table prefix, and also an optional filename if the default file name is not appropriate.

Each database may contain more than one wiki, these will be uniquely identified using table prefixes.

First principles using mysqldump

Backup and compress DB & FS
mysqldump -u [user] --password='**********' --default-character-set=latin1 -A > | 7za a -si backupfile.sql.7z # Backup
tar cf - directory | 7za a -si backupfile.t7z
mysqldump -u [user] --password='**********' --single-transaction --default-character-set=latin1 -B [database] > backupfile.sql # Backup
mysql -u [user] -p [database] < backupfile.sql # Restore

Character encoding issues

There can be some problems with MySQL dumps concerning character encodings. Most of these problems are covered here. It seems that to ensure you have a proper UTF-8 encoded text file you must set the character set to latin1. When importing this dump you may need to manually change the /*!40101 SET NAMES latin1 */ to /*!40101 SET NAMES utf8 */.

These problems don't always seem to occur - I have usually had no trouble with non latin1 exports being reimported again with special characters working fine even though looking at the dump in a text editor shows mangled characters. But sometimes - perhaps depending on the versions of the MySQL servers being imported and exported between - these special steps need to be taken.

See also