summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/lh_system_restore_job
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2011-12-30 19:03:20 (GMT)
committerJames Meyer <james.meyer@operamail.com>2011-12-30 19:03:20 (GMT)
commit68def16b69900b781eab3f36f27d94eaf42a360b (patch)
tree55ae3b3f8a8611d73e1b2e4eb2bb12fe9c6d9fdd /abs/core/LinHES-system/lh_system_restore_job
parentf01f4a6a837ccbdc55107bb0738846b5a56f1462 (diff)
downloadlinhes_pkgbuild-68def16b69900b781eab3f36f27d94eaf42a360b.zip
linhes_pkgbuild-68def16b69900b781eab3f36f27d94eaf42a360b.tar.gz
linhes_pkgbuild-68def16b69900b781eab3f36f27d94eaf42a360b.tar.bz2
linhes-system: add new utils for backup/update/and restore
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