Wikimedia sync script

From mediawiki.org

It is possible to keep your MediaWiki install automatically synced with the Wikimedia wikis by way of a script. This can be a good idea because your wikis are automatically up to date and you will have the same functionality as the Wikimedia wikis (without the terror of absolute bleeding edge).

  1. Save the script below as wikimediaupdate.pl
  2. chmod +x wikimediaupdate.pl
  3. Add a job to your crontab for it to run as often as you want (once a day should be fine):
    0 3 * * * /path/to/wikimediaupdate.pl

It's probably a good idea to add a script that creates backups on a regular basis as well…

Script[edit]

By Andrew Garrett, under a "do whatever you want with it" license:

 
#!/usr/bin/perl -w

use LWP::Simple;

my $text = get 'http://en.wikipedia.org/w/api.php?action=query&meta=siteinfo&format=txt';

if ($text =~ /\[rev\] \=\> (\d+)/) {
    $rev = $1;
} else {
    die "Can't get Wikimedia's SVN revision";
}

print "Updating to r$rev\n";

`svn up /path/to/base/of/mediawiki/install/ -r $rev`;
`php /path/to/base/of/mediawiki/install/maintenance/update.php`;