Mediawiki notes on upgrading/Mediawiki backup

From Bjoern Hassler's website
Jump to: navigation, search

WARNING - This hasn't been well tested yet! The instructions on Mediawiki notes on upgrading are well tested, so if in doubt, read those!

Some quick notes on mediawiki backup, also needed if you want to move an entire mediawiki.

Before you do this, read Mediawiki notes on upgrading regarding the latin1 issue, and select the appropriate commands below!

Improvements: Automatically get dbuser and password from AdminSettings.php.

[ View code | Edit code | Download]
print "Make sure that you have AdminSettings.php set up properly!";

if ($#ARGV != 1) {
Please provide two arguments!                                                                                                                                                                                   
$0 DBUSER WIKIDIR                                                                                                                                                                                               

($user,$wikidir) = @ARGV;

if (!-e "$wikidir/AdminSettings.php") {
    print "No AdminSettings in sight!";

($date = `date '+%Y%m%d_%H%M%S'`) =~ s/\n//;
$dir = "wiki_backup_" . $date;

if (-e $dir) {
    exit("$dir exists.");
print "Database backup:\n";
system "mysqldump -u $user -p --all-databases  -c | gzip > $dir/database/MYSQL_BACKUP_$dat.txt.gz;                                                                                                              
mysqldump -u $user -p --all-databases -c --default-character-set=latin1 | gzip > $dir/database/MYSQL_BACKUP_latin1_$date.txt.gz;                                                                                
mysqldump -u $user -p --all-databases -c --xml | gzip > $dir/database/MYSQL_BACKUP_XML_$date.xml.gz;                                                                                                            
mysqldump -u $user -p --all-databases -c --xml --default-character-set=latin1 | gzip > $dir/database/MYSQL_BACKUP_XML_latin1_$date.xml.gz;                                                                      
print "Page dump:\n";
system "php wiki/maintenance/dumpBackup.php --full | gzip > $dir/pages/AllWikiPages_$date.gz";
print "Wiki backup:\n";
system "cp -rip $wikidir $dir";
print "Making tar archive:\n";
system "tar cf wiki_backup_$date.tar $dir; gzip wiki_backup_$date.tar";
system "chmod go-rx wiki_backup_$date.tar.gz $dir";

print "Please archive                                                                                                                                                                                           
somewhere. You can now delete the temporary dir:                                                                                                                                                                
Make sure you obscure your AdminSettings.php (including the copy in the backup!)                                                                                                                                

The file wiki_backup.tgz now contains all you need to completely reinstall the wiki elsewhere, or just to put the pages/images onto a different wiki.