Mediawiki Backup

I built a internal Mediawiki site for my company. A easy place to combine useful information. I recently came up with a backup script that I find rather useful and since I’m a nice guy I decided to share it, ok ok I have an alter motive I admit it! I’m a believer in open source, the more people editing the software the better it gets, so by all means, if you notice something about this script and you think “what an idiot he could have just done it this way and it would have been eaiser / more efficent. by all means let me know! =) thanks!

#!/bin/sh

#--------------------------------------------
# CHANGE THESE OPTIONS TO MATCH YOUR SYSTEM !

wikiname=insight   # wiki name (used for backup filenames)
wikidb="wikidb"   # the database your wiki stores data in
wikidir=/var/www/   # the directory mediawiki is installed in
backupdir=~/bak   # the directory to write the backup to

#---------------
# END OF OPTIONS

timestamp=`date +%Y-%m-%d`
db="$backupdir/$wikiname-$timestamp.sql.gz"
xml="$backupdir/$wikiname-$timestamp.xml.gz"
file="$backupdir/$wikiname-$timestamp.files.tgz"

#---------------------------------
# Put the wiki into Read-only mode

echo
echo "Putting the wiki in Read-only mode..."
echo "$wgReadOnly = 'Dumping Database, Access will be restored in ~ 1 min.';" >> "$wikidir"/LocalSettings.php

echo
echo "creating database dump, $db..."
mysqldump --default-character-set=latin1 --user=XXXX --password=XXXX "$wikidb" | gzip > "$db" || exit $?

echo
echo "creating XML dump, $xml..."
cd "$wikidir/maintenance"
php -d error_reporting=E_ERROR dumpBackup.php --full | gzip > "$xml" || exit $?

echo
echo "creating file archive, $file..."
cd "$wikidir"
tar --exclude .svn -zcf "$file" . || exit $?

#-----------------------------------------
# Put the wiki back into read/write mode

echo
echo "Bringing the wiki out of Read-only mode..."

head -n-1 "$wikidir"/LocalSettings.php > "$backupdir"/LocalSettings.bak
cat "$backupdir"/LocalSettings.bak > "$wikidir"/LocalSettings.php
rm "$backupdir"/LocalSettings.bak

#-----------------------
# Creating TAR archive

echo
echo "Creating TAR archive"

tar -cf $backupdir/$wikiname-$timestamp.tar $db $xml $file
rm $db $xml $file

echo
echo "Done!"

#----
# END
No tips yet.
Be the first to tip!

Like this post? Tip with bitcoin!

16mMRWykMT32soqbatRF1EuAFo2q7h3Wov

If you enjoyed reading this post, please consider tipping me using Bitcoin. Each post gets its own unique Bitcoin address so by tipping you're not only making my continued efforts possible but telling me what you liked.

Adding Google Analytics to WordPress

I’ve looked all over for a plugin to install Google Analytics on a WordPress blog, finally I got fed up as all the plugins only provide the basic (urchin.js) script and not the newer advanced script (ga.gs)

I decided to share with everyone how easy it really is to do this yourself with the built in Theme Editor.

The Theme EditorNext step is to located and select the “Footer” from the right hand menu. Now scroll all the way down and paste your code in right before the tag.The Editor

After realizing how easy this  really was it really makes you think why people really even need to develop a plugin for it as the act of installing the plugin is more work then adding Google Analytics to your wordpress blog.

No tips yet.
Be the first to tip!

Like this post? Tip with bitcoin!

1ChD4XHZaXVzeHJsFgG2BaKKf1nwrF8Fkb

If you enjoyed reading this post, please consider tipping me using Bitcoin. Each post gets its own unique Bitcoin address so by tipping you're not only making my continued efforts possible but telling me what you liked.