User:Paranormal Skeptic/wiki-backup.sh

Below is the invocation of the script:

wiki_backup.sh (database where the wiki is) (db account name) (db account password) (Path To Wiki)

The following is the script:


 * 1) !/bin/bash

db=$1

root=$2

pass=$3

wikipath=$4

dte=`date +%j`

backupdir=gimme your backup directory here

echo "Shuttdown Apache..."


 * 1) apache2ctl stop

echo "Performing backup of $db"

/usr/bin/mysqldump -u $root --password=$pass $db -c > /tmp/wiki-$db.sql

tar cvf /tmp/wiki-$db.tar $wikipath

echo "Starting Apache back up..."


 * 1) apache2ctl start

tar cvf $backupdir/wiki-$db-$dte.tar /tmp/wiki-$db.*

rm /tmp/wiki-$db.*

echo "Backup complete!"

I stop Apache when this runs, and fires it back up when it's done. Uncomment it to do the same.