summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/lh_system_restore_job
diff options
context:
space:
mode:
authorCecil <knoppmyth@gmail.com>2012-01-14 20:46:12 (GMT)
committerCecil <knoppmyth@gmail.com>2012-01-14 20:46:12 (GMT)
commitc321283760591e3c6e5d9ed415e9c422fee83d9e (patch)
tree4e482fdf514f477c7ac23e0da81ec82a51a53b39 /abs/core/LinHES-system/lh_system_restore_job
parente9948fef7a06dbb6b0c53e50df10c0a0dc2d941b (diff)
parentd5525acd5a4054460b98930b46d9de5690c1fd36 (diff)
downloadlinhes_pkgbuild-c321283760591e3c6e5d9ed415e9c422fee83d9e.zip
linhes_pkgbuild-c321283760591e3c6e5d9ed415e9c422fee83d9e.tar.gz
linhes_pkgbuild-c321283760591e3c6e5d9ed415e9c422fee83d9e.tar.bz2
Merge branch 'testing' of ssh://cesman@linhes.org/mount/repository/linhes_pkgbuild into testing
Diffstat (limited to 'abs/core/LinHES-system/lh_system_restore_job')
-rw-r--r--abs/core/LinHES-system/lh_system_restore_job76
1 files changed, 76 insertions, 0 deletions
diff --git a/abs/core/LinHES-system/lh_system_restore_job b/abs/core/LinHES-system/lh_system_restore_job
new file mode 100644
index 0000000..9c66e2a
--- /dev/null
+++ b/abs/core/LinHES-system/lh_system_restore_job
@@ -0,0 +1,76 @@
+#!/bin/bash
+# This script is used to perform a quick restore of a database that was backed up via the nightly system backup
+# The restore only does the database it does NOT restore system files (even if they are in the backup file)
+#
+BACKUPDIR=/myth/system_backups
+backupfile=$1
+
+function usage(){
+ echo "------------------------------------------------------"
+ echo "This program will restore the database from a system backup."
+
+ echo "Files are expected to be in the $BACKUPDIR"
+ echo "usage:"
+ echo ""
+ echo "lh_system_restore_job \$filename [yes]"
+ echo ""
+ echo "example: lh_system_restore_job backup.2011-12-22_15-34.tgz "
+ echo ""
+ echo ""
+
+ echo "If the script is passed a second argument, it will not cleanup the the restore dir."
+ echo "------------------------------------------------------"
+
+ exit 1
+ }
+
+
+
+if [ x$backupfile = x ]
+then
+ usage
+fi
+
+. /etc/profile
+
+RESTOREDIR=$BACKUPDIR/restore
+DIR=`echo $backupfile |cut -d. -f2`
+CSQL="create database mythconverg;"
+DSQL="drop database mythconverg; "
+MYSQL="mysql -u mythtv -pmythtv"
+
+
+
+mkdir -p $RESTOREDIR
+cp $BACKUPDIR/$backupfile $RESTOREDIR
+cd $RESTOREDIR && tar -xf $backupfile && cd $DIR
+
+if [ -f mythconverg ]
+then
+ #drop the db
+ $MYSQL -e "$DSQL"
+ #create the db
+ $MYSQL -e "$CSQL"
+ #restore the database_backup
+ echo "Restoring the database $DIR"
+ $MYSQL mythconverg < mythconverg
+ if [ $? = 0 ]
+ then
+ echo "Done"
+ else
+ echo "An error occured"
+ fi
+ else
+ echo "Couldn't file a file to restore"
+fi
+
+
+#cleanup
+if [ x$2 = x ]
+then
+ echo "Cleaning up the restore dir"
+ rm -rf $RESTOREDIR/$DIR
+ rm -f $RESTOREDIR/$backupfile
+else
+ echo "Not doing a cleanup of $RESTOREDIR"
+fi