Difference between revisions of "Manually backup a wiki"
(Change source-code blocks to standard format) |
|||
(One intermediate revision by one other user not shown) | |||
Line 8: | Line 8: | ||
=== First principles using mysqldump === | === First principles using mysqldump === | ||
;Backup and compress DB & FS | ;Backup and compress DB & FS | ||
− | + | <source lang="bash"> | |
− | <bash> | ||
mysqldump -u [user] --password='**********' --default-character-set=latin1 -A > | 7za a -si backupfile.sql.7z # Backup | mysqldump -u [user] --password='**********' --default-character-set=latin1 -A > | 7za a -si backupfile.sql.7z # Backup | ||
tar cf - directory | 7za a -si backupfile.t7z | tar cf - directory | 7za a -si backupfile.t7z | ||
− | </ | + | </source> |
− | |||
− | + | <source lang="bash"> | |
− | <bash> | ||
mysqldump -u [user] --password='**********' --single-transaction --default-character-set=latin1 -B [database] > backupfile.sql # Backup | mysqldump -u [user] --password='**********' --single-transaction --default-character-set=latin1 -B [database] > backupfile.sql # Backup | ||
mysql -u [user] -p [database] < backupfile.sql # Restore | mysql -u [user] -p [database] < backupfile.sql # Restore | ||
− | </ | + | </source> |
− | |||
== Character encoding issues == | == Character encoding issues == | ||
Line 29: | Line 25: | ||
== See also == | == See also == | ||
*[[Backup]] | *[[Backup]] | ||
+ | *[[Change the character-set of a wiki database]] |
Latest revision as of 18:11, 22 May 2015
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.