From ca2aef36c8c280f61d14ba16f9efc03e014e3162 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 22 Sep 2015 18:25:24 +0200 Subject: Add dozmod database upgrade script to restore feature --- scripts/system-restore | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'scripts') diff --git a/scripts/system-restore b/scripts/system-restore index 7b0de12..b9fe9d0 100755 --- a/scripts/system-restore +++ b/scripts/system-restore @@ -1,5 +1,7 @@ #!/bin/bash +TMDIR="/opt/taskmanager" + BACKUP="$1" if [ -z "$BACKUP" ] || [ ! -f "$BACKUP" ]; then echo "Backup file not found: $BACKUP" @@ -77,16 +79,24 @@ if [ $RES_OPENSLX -eq 1 -a ! -f files.tgz ]; then exit 1 fi +echo "-- Restoring Database" if [ $DB_OLD -eq 1 ]; then + echo "--- Importing legacy database dump" + # Restoring from dozmod v1.0 db mysql --defaults-extra-file=/etc/mysql/debian.cnf --default-character-set=utf8 < db.sql RET=$? + echo "--- Trying to convert dozmod data (this might not work too well...)" + mysql --defaults-extra-file=/etc/mysql/debian.cnf --default-character-set=utf8 < "${TMDIR}/data/dozmod-upgrade.sql" else + # Restoring from v1.1+ db RET=0 if [ $RES_SAT -eq 1 ]; then + echo "--- Importing system configuration" mysql --defaults-extra-file=/etc/mysql/debian.cnf --default-character-set=utf8 < sat.sql RET=$? fi if [ $RET -eq 0 -a $RES_OPENSLX -eq 1 ]; then + echo "--- Importing dozmod database (vms/lectures meta data)" mysql --defaults-extra-file=/etc/mysql/debian.cnf --default-character-set=utf8 < openslx.sql RET=$? fi @@ -98,6 +108,7 @@ if [ $RET -ne 0 ]; then fi if [ $RES_OPENSLX -eq 1 ]; then + echo "-- Restoring system files" # Since we came that far we'll delete some old configs (if existent) rm -rf /opt/ldadp/{configs,pid,logs}/* /opt/openslx/configs/* /srv/openslx/www/boot/default/config.tgz 2> /dev/null # Force triggering IP detection/setting, which should in turn regenerate ldadp configs and launch ldadp instances if applicable -- cgit v1.2.3-55-g7522