Monday, July 13, 2009

Backup/restore a MediaWiki

In certain situations, you may want to backup wiki repository, e.g, for future server migration or switch to another machine. Here are guidelines to backup a MediaWiki and restore it.
Before that let's make couple of assumptions
  • Wiki database name - foo
  • Wiki database username - tim
  • Wiki database password - lyfavour
1) backup wiki database with below mysql command
mysqldump --database foo -u tim -plyfavour --add-drop-table --single-transaction -B > $(date +%Y%m%d).sql
2) copy images, settings and skins and compress them with database backup file into a single zip file
zip -r ./backup/$(date +%Y%m%d).zip /rtpc/www/wiki/images/ /rtpc/www/wiki/extensions/ /rtpc/www/wiki/includes/ /rtpc/www/wiki/skins/ LocalSettings.php $(date +%Y%m%d).sql -x backup/

Now let's take some steps to recover the wiki
  • Decompress backup file
  • Copy $(backup)/skins to $(new_wiki)/
  • Copy $(backup)/extensions to $(new_wiki)/
  • Copy $(backup)/images to $(new_wiki)/
  • Copy $(backup)/includes to $(new_wiki)/
  • Copy $(backup)/$db to /var/lib/mysql/$(new_wiki_db)
  • Repaire search index in mysql environment with
  • mysql> use $(new_wiki_db);
  • mysql> check table searchindex;
  • mysql> repair table searchindex

No comments:

Post a Comment