Backing and Restoring Mediawiki in Ubuntu
We are going to learn how to back up and restore our Mediawiki installed on a Ubuntu system.
To acomplish that we will execute some wiki maintenance commands.
These maintenance commands will be accesible after configuring AdminSettings.php file.
CONFIGURING AdminSettings.php FILE
AdminSettings.sample from the Mediawiki examples documentation will serve us as a model file to start.
We copy it into mediawiki configuration directory in /etc and assign the correct owner and permissions.
$sudo cp /usr/share/doc/mediawiki1.10/examples/AdminSettings.sample /etc/mediawiki1.10/AdminSettings.php
$sudo chown root:root /etc/mediawiki1.10/AdminSettings.php
$sudo chmod 600 /etc/mediawiki1.10/AdminSettings.php
Now we are going to edit AdminSettings.php file
$gksudo gedit /etc/mediawiki1.10/AdminSettings.php
Change these two variables using the parameters you used when creating the wiki database: e.g: wikiuser and its password.
$wgDBadminuser = 'DB user name'
$wgDBadminpassword = 'DB password'
Now that AdminSettings.php file is properly configured we are gonna back up and restore the wiki.
BACKING UP THE WIKI
dumpBackup.php command will back up our wiki:
$cd /var/lib/mediawiki1.10/maintenance
$sudo php dumpBackup.php --current > ~/foo_backup.xml
NOTE: --full option backups history of pages, not only last version as --current does.
RESTORING THE WIKI
importDump.php is the command we need:
$cd /var/lib/mediawiki1.10/maintenance
$sudo php importDump.php ~/foo_backup.xml
If after importing the xml file we still do not see anything in the wiki, we shall exec:
$sudo php rebuildrecentchanges.php
or
$sudo php update.php
NOTE: Those previous commands only back up and restore the text part of the wiki. They just create an xml with text.
Following commands shows how to backup and restore images in your wiki:
BACKING UP THE IMAGES OF YOUR WIKI
NOTE: As now, the wiki is placed mostly in /var/lib/mediawiki directory, we will assume the wiki is placed there, instead of /var/lib/mediawiki1.10 . This also suites better new wiki versions.
We create the directory where we will store the wiki image files:
$mkdir image_backup_dir && cd image_backup_dir
dumpUploads.php command shows all wiki image file locations.
We use this command output to copy all those files to our storage directory:
$sudo php /var/lib/mediawiki/maintenance/dumpUploads.php --base=$(pwd) | xargs -I foo cp 'foo' . -v
--base option tells dumpUploads.php command that all file places should be related to current directory.
xargs -I foo cp 'foo' . -v reads every file location from standard input and copies it to current directory.
If there has been no error, our current directory is populated now with the wiki image and media files.
RESTORING THE IMAGES OF YOUR WIKI
Once you have created image_backup_dir directory containing all the wiki image files we could restore them.
We execute importImages.php command and pass as argument the path to our image_backup_dir directory where all the images are:
$sudo php /var/www/mediawiki/maintenance/importImages.php image_backup_dir
Your wiki will show now all the images.
YOU MAY ALSO BE INTERESTED IN
Installing and Configuring Mediawiki on a Ubuntu Gutsy Desktop System
Installing Mediawiki using SQLite Database in GNU/Debian
4 comentarios:
hi, does this back up images and SQL files? or just the xml?
Hi fotoflo,
sorry for the delay.
dumpBackup.php and importBackup.php commands only back up the wiki text.
Now I have updated the blog entry showing how to also back up and restore images in the wiki.
Thanks,
Vicente.
I think you have a typo using --base, there's an '=' missing.
Here's my exporter script:
cp `php /var/lib/mediawiki/maintenance/dumpUploads.php --base=$(pwd) | xargs` ./
and importer script:
php /var/lib/mediawiki/maintenance/importImages.php ./
Hi Re@PeR,
thanks a lot for you comment!
It is corrected now.
Post a Comment