Wiki - backing up
As much as I love having a online notebook, it is prone to spam and a couple of times my web hosting company has mucked things up and corrupted my database. Every so often I try and remember to make a backup of all my pages in case my site goes down again.
Methods To Backup MediaWiki
The methods to backup I use are:
Method 1 - Use "Export Page"
- Open [ Special:Allpages ] in Internet Explorer or Chrome (in firefox it copies differently)
- Copy all entries (which are arranged in three columns)
- Paste into Microsoft Excel, rearrange into a single column, sort, and copy
- Open [ Special:Export ] and paste in list of all pages
- Add special pages such as "NoskeWiki:About", "NoskeWiki:Privacy_policy", "NoskeWiki:Copyrights" and "NoskeWiki:General_disclaimer" which may be missing... and also Special:Categories and Special:MostLinkedTemplates / Special:UncategorizedTemplates if you have categories and templates. (see: Wiki - list of pages)
- Save the XML output of all pages as "wiki_backup_(29-01-2008)_export.xml"
- NOTE: This option is relatively quick, but you'll have to replace many characters like "& lt;" etc .
- NOTE: This option won't save images, see the last section for that.
- NOTE: There is also a method using "/maintenance/dumpBackup.php", however this requires you to setup "/AdminSettings.php" with SQL details, which I'm not willing to do yet, because MediaWiki is prone to hacking.
Method 2 - Use phpMyAdmin
- Open my web hosting site
- Log into CPanel and click "phpMyAdmin" (down the bottom)
- Click wikidb (left hand column)
- Click Export
- Select XML and "save as file" - "wiki_backup_(29-01-2008)_phpmyadmin.xml"
- NOTE: This results in a file which is very large by comparison, but might be useful because it (theoretically) contains all the info I'd need to set the wiki up exactly as before, with same the users and everything.
About the MediaWiki Database
Doing an export of the entire database is a mess - you can reduce the mess slightly if you just export the XML for the most important tables. If look at your MediaWiki database using a tool like "phpMyAdmin", you'll see numerous tables. Many of these tables contain user information and various editing info, and in my case I really only want the latest state of the text. Here are some I have found to the be most important:
- archive - sounds important, but doesn't look like it is.
- page - doesn't contain text, but has a list of every page and image plus its last edit number. The page / image name is in the
- revision - similar to above, but .
- text ** - contains a giant list with ALL THE TEXT from each edit - sorted in chronological order. This means you'll have multiple entries for each page, but if you manage to isolate the latest change for each page then you'll have done well. If you work your way up the list from the bottom you can see all the latest edits.
- images * - shows a list of every image plus some metadata. The image itself is stored in a directory with the names hashed, and apparently there's a way to extract the names and images that way, but I've never tried myself.
Backing up Images
- The easiest way to save all images is to do an FTP copy of the w/images/ directory and you'll get all your images under cryptic sub-directories like "/public_html/andrewnoske/w/images/b/bf/Image_name.jpg". It's messy, but should get all of them, plus thumbnail of various size under "/public_html/andrewnoske/wiki_old/images/thumb/2/29/Image_name.jpg/220px-Image_name.jpg".
- TIP: To make things cleaner I add pages with images to a category called Category:Images and save all images I upload to a local folder on my hard-drive called "WIKI_IMAGES".
- Wiki - restoring - for if/when I need to restore a backup.
- MediaWiki.org - Manual:Backing up a wiki - proper guide.