|
|
Contributed by Olaf Zevenboom
|
|
|
|
|
|
use at your own risk.
|
|
|
|
|
|
Original: <http://brightbyte.de/page/MediaWiki_backup>
|
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
####################################################################
|
|
|
# #
|
|
|
# Basic Backup Script for MediaWiki. #
|
|
|
# Created by Daniel Kinzler, brightbyte.de, 2008 #
|
|
|
# #
|
|
|
# This script may be freely used, copied, modified and distributed #
|
|
|
# under the sole condition that credits to the original author #
|
|
|
# remain intact. #
|
|
|
# #
|
|
|
# This script comes without any warranty, use it at your own risk. #
|
|
|
# #
|
|
|
####################################################################
|
|
|
|
|
|
###############################################
|
|
|
# CHANGE THESE OPTIONS TO MATCH YOUR SYSTEM ! #
|
|
|
###############################################
|
|
|
|
|
|
#wikidb="daniel_wiki" # the database your wiki stores data in
|
|
|
wikidb="wikidb" # the database your wiki stores data in
|
|
|
#mysqlopt="-u username -ppassword" # any options used for interacting with mysql
|
|
|
mysqlopt="" # usually empty if username and password are provided in your
|
|
|
.my.cnf
|
|
|
|
|
|
wikidir=/var/www/intranet.artefact.com/mediawiki-1.5.0 # the directory mediawiki is installed in
|
|
|
backupdir=/home/storage/backupdump # the directory to write the backup to
|
|
|
|
|
|
##################
|
|
|
# END OF OPTIONS #
|
|
|
##################
|
|
|
|
|
|
# added by OZ
|
|
|
test ! -d $backupdir && mkdir $backupdir
|
|
|
wikiDBserver=`grep '^\$wgDB' $wikidir/LocalSettings.php |grep "DBserver" | cut --delimiter="=" -f2 | cut --delimiter="\"" -f2`
|
|
|
wikiDBname=`grep '^\$wgDB' $wikidir/LocalSettings.php |grep "DBname" | cut --delimiter="=" -f2 | cut --delimiter="\"" -f2`
|
|
|
wikiDBuser=`grep '^\$wgDB' $wikidir/LocalSettings.php |grep "DBuser" | cut --delimiter="=" -f2 | cut --delimiter="\"" -f2`
|
|
|
wikiDBpassword=`grep '^\$wgDB' $wikidir/LocalSettings.php |grep "DBpassword" | cut --delimiter="=" -f2 | cut --delimiter="\"" -f2`
|
|
|
wikidb=$wikiDBname
|
|
|
mysqlopt="--host=$wikiDBserver --user=$wikiDBuser --password=$wikiDBpassword --skip-lock-tables"
|
|
|
# end of additions
|
|
|
|
|
|
timestamp=`date +%Y-%m-%d`
|
|
|
|
|
|
dbdump="$backupdir/wiki-$timestamp.sql.gz"
|
|
|
xmldump="$backupdir/wiki-$timestamp.xml.gz"
|
|
|
filedump="$backupdir/wiki-$timestamp.files.tgz"
|
|
|
|
|
|
echo "Wiki backup. Database: $wikidb; Directory: $wikidir; Backup to: $backupdir"
|
|
|
echo
|
|
|
echo "creating database dump $dbdump..."
|
|
|
mysqldump --default-character-set=latin1 $mysqlopt "$wikidb" | gzip > "$dbdump" || exit $?
|
|
|
|
|
|
echo
|
|
|
echo "creating XML dump $xmldump..."
|
|
|
cd "$wikidir/maintenance"
|
|
|
php -d error_reporting=E_ERROR dumpBackup.php --full | gzip > "$xmldump" || exit $?
|
|
|
|
|
|
echo
|
|
|
echo "creating file archive $filedump..."
|
|
|
cd "$wikidir"
|
|
|
tar --exclude .svn -zcf "$filedump" . || exit $?
|
|
|
|
|
|
echo
|
|
|
echo "Done!"
|
|
|
echo "Files to copy to a safe place: $dbdump, $xmldump, $filedump"
|
|
|
|
|
|
#######
|
|
|
# END #
|
|
|
####### |