Simple MediaWiki Backup: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 190: | Line 190: | ||
[[Category:Internet Committee]] |
[[Category:Internet Committee]] |
||
[http://update-seputar-software.blogspot.com/2011/12/ultrabook-notebook-tipis-harga-murah.html Ultrabook Notebook Tipis Harga Murah Terbaik] |
Revision as of 13:01, 11 March 2012
MediaWiki is one of my favorite pieces of software. Not because its code is elegant (LocalSettings.php? bleh), or because it has such a succinct but useful set of features (skins!). No, the thing about MediaWiki is that it does a great job of being a wiki.
I'm sure there has to be a better piece of wiki software out there, but I've not yet found it.
So, in the interest helping out other MediaWiki aficionados, here are three scripts which I use when I'm doing upgrades. This is only half the battle (the backing up half.)
Backup Scripts
Notes
- These scripts are designed for use with mysql as the backend to the wiki. Other databases require the scripts to be adapted appropriately.
- There are redundancies in running backupAll.bash. (hint: the databases). Why? Because when I run backupAll.bash, I want to backup everything. I want to backup the mysql server. I want to backup the wiki. There could be other things in backupAll.bash, but the listing here only includes the wiki related stuff. But, each backup should be atomic. So, backupWiki.bash should backup the wiki and its dependents. backupDB.bash should backup the database. I don't worry that in there the database is getting backed up (or dumped, more precisely) twice. Better twice than not at all.
- So, in regards to the above bullet point, you can run backupWiki.bash by itself and have your wiki backed up.
- Why backup? Because with a backup in hand, you can safely upgrade your wiki to the latest version, which means you install cool extensions.
backupAll.bash
#!/bin/bash export scriptDir=/root if [ -z $1 ] then echo "Invalid backup label." exit 1; fi echo "Backing DB up to label $1" echo "_________________________" $scriptDir/backupDB.bash $1 echo "" echo "" echo "Backing Wiki up to label $1" echo "_________________________" $scriptDir/backupWiki.bash $1 echo "" echo ""
backupDB.bash
#!/bin/bash if [ -z $1 ] then echo "Invalid backup label." exit 1; fi export dbUser=root export password=supersecret export mysqlSQL=mysql.$1.sql export wikidbSQL=wikidb.$1.sql export mysqlBZ2=$mysqlSQL.bz2 export wikidbBZ2=$wikidbSQL.bz2 echo "Creating dump of mysql..." mysqldump -u $dbUser --password=$password mysql > $mysqlSQL echo "Creating dump of wikidb..." mysqldump -u $dbUser --password=$password wikidb > $wikidbSQL if [ -f $mysqlBZ2 ] then echo "Removing old backups of $mysqlBZ2..." rm -r $mysqlBZ2 fi if [ -f $wikidbBZ2 ] then echo "Removing old backups of $wikidbBZ2..." rm -r $wikidbBZ2 fi echo "Zipping up $mysqlBZ2..." bzip2 $mysqlSQL echo "Zipping up $wikidbBZ2..." bzip2 $wikidbSQL
backupWiki.bash
#!/bin/bash if [ -z $1 ] then echo "Invalid backup label." exit 1; fi export destFile=wikiBackup.$1.tar.bz2 export temp=/tmp export backupWiki=backupWiki export tempDir=$temp/backupWiki export srv=/srv export mediaWiki=mediawiki export mediaWikiPath=$srv/$mediaWiki export wikiDB=wikidbB export password=supersecret # Remove the temporary directory if it exists. if [ -d $tempDir ] then echo "Removing temporary directory $tempDir..." rm -rf $tempDir fi # If the backup file exists, delete it. if [ -f $destFile ] then echo "Removing old backup file $destFile..." rm $destFile fi # Create the temporary directory. echo "Creating temporary directory $tempDir..." mkdir $tempDir # Get the database dumps. echo "Creating database dumps..." mysqldump -u root --password=$password mysql > $tempDir/mysql.sql mysqldump -u root --password=$password $wikiDB > $tempDir/wikidb.sql # Get the important files from mediawiki. echo "Creating backups of settings php files and vhost..." cp /etc/apache2/vhosts.d/wiki.conf $tempDir cp $mediaWikiPath/LocalSettings.php $tempDir cp $mediaWikiPath/AdminSettings.php $tempDir # Backup the mediawiki directory. echo "Backing up mediawiki directory..." tar --create --bzip2 --directory=$srv --file=$tempDir/mediawiki.tar.bz2 $mediaWiki # Create the master backup. echo "Creating master backup $destFile from $tempDir..." tar --create --bzip2 --directory=$temp --file=$destFile $backupWiki # Remove the temporary directory if it exists. if [ -d $tempDir ] then echo "Removing temporary directory $tempDir..." rm -rf $tempDir fi
What a backup entails...
yoda:~ # ./backupAll.bash test Backing DB up to label test _________________________ Creating dump of mysql... Creating dump of wikidb... Removing old backups of mysql.test.sql.bz2... Removing old backups of wikidb.test.sql.bz2... Zipping up mysql.test.sql.bz2... Zipping up wikidb.test.sql.bz2... Backing Wiki up to label test _________________________ Removing temporary directory /tmp/backupWiki... Creating temporary directory /tmp/backupWiki... Creating database dumps... Creating backups of settings php files and vhost... Backing up mediawiki directory... Creating master backup wikiBackup.test.tar.bz2 from /tmp/backupWiki... Removing temporary directory /tmp/backupWiki...