summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--[-rwxr-xr-x]abs/core-testing/LinHES-system/bin/backupcommon143
-rwxr-xr-xabs/core-testing/LinHES-system/bin/checkbackup2
-rwxr-xr-xabs/core-testing/LinHES-system/bin/checkrestore2
-rwxr-xr-xabs/core-testing/LinHES-system/bin/library.sh164
-rwxr-xr-xabs/core-testing/LinHES-system/bin/mythbackup30
-rwxr-xr-xabs/core-testing/LinHES-system/bin/mythrestore22
-rwxr-xr-xabs/core-testing/LinHES-system/bin/rollback.sh20
7 files changed, 310 insertions, 73 deletions
diff --git a/abs/core-testing/LinHES-system/bin/backupcommon b/abs/core-testing/LinHES-system/bin/backupcommon
index a5ed7c0..9b75db3 100755..100644
--- a/abs/core-testing/LinHES-system/bin/backupcommon
+++ b/abs/core-testing/LinHES-system/bin/backupcommon
@@ -1,12 +1,16 @@
#!/bin/bash
+. /usr/LH/bin/library.sh || {
+ echo 1>&2 "Can not load common library!"
+ exit 1
+}
+
#----------------------------------------------------------------------------
DATABASE="mythconverg"
-DATABASE_DIR="/var/lib/mysql/$DATABASE"
+DATABASE_DIR="/data/srv/mysql/$DATABASE"
BACKUP_LIST="./root ./home ./etc
- ./var/www/mythweb/.htaccess ./var/lib/alsa/asound.state"
-RESTORE_LIST="./root ./home ./etc/mythtv/modules ./etc/lirc ./etc/htdigest
- ./etc/apache2/apache2.conf ./var/www/mythweb/.htaccess
+ ./var/lib/alsa/asound.state"
+RESTORE_LIST="./root ./home ./etc/mythtv/modules ./etc/lirc
./etc/X11/xorg.conf ./etc/asound.conf ./etc/default/aumix
./var/lib/alsa/asound.state ./etc/mplayer/mplayer.conf
./etc/localtime ./etc/timezone"
@@ -41,14 +45,54 @@ BACKUP_EXTRAS="$BACKUP_DIR/backup.list"
RESTORE_EXTRAS="$BACKUP_DIR/restore.list"
BACKUP_TAR="$BACKUP_DIR/savedfiles.tar"
BACKUP_SQL="$BACKUP_DIR/$DATABASE.sql"
-DROP_SQL="/usr/local/share/knoppmyth/drop.sql"
+#DROP_SQL="/usr/local/share/knoppmyth/drop.sql"
+UTIL_DIR="/usr/LH/bin"
# Do we really still need to update from myth-0.11 to myth-0.12 ?
UPDATE_SQL="/usr/share/mythtv/sql/0.11-to-0.12.sql"
-UPDATE_FILES="/usr/local/bin/restore_fixups.sh"
+UPDATE_FILES="$UTIL_DIR/restore_fixups.sh"
COMPRESSION=".gz"
SOUNDS="/usr/share/sounds"
PLAYER="/usr/bin/aplay"
#----------------------------------------------------------------------------
+AWK=/bin/awk
+BASH=/bin/bash
+BUNZIP2=/bin/bunzip2
+BZIP2=/bin/bzip2
+CAT=/bin/cat
+CHMOD=/bin/chmod
+CHOWN=/bin/chown
+EGREP=/bin/egrep
+GREP=/bin/grep
+GUNZIP=/bin/gunzip
+GZIP=/bin/gzip
+LS=/bin/ls
+MV=/bin/mv
+RM=/bin/rm
+SED=/bin/sed
+TAR=/bin/tar
+TR=/bin/tr
+DIFF=/usr/bin/diff
+FIND=/usr/bin/find
+MD5SUM=/usr/bin/md5sum
+MYISAMCHK=/usr/bin/myisamchk
+MYSQL=/usr/bin/mysql
+MYSQLADMIN=/usr/bin/mysqladmin
+MYSQLDUMP=/usr/bin/mysqldump
+MYTHSHUTDOWN=/usr/bin/mythshutdown
+SORT=/usr/bin/sort
+WC=/usr/bin/wc
+SV=/sbin/sv
+
+#----------------------------------------------------------------------------
+
+require file+r+x $AWK $BASH $BUNZIP2 $BZIP2 $CAT $CHMOD $CHOWN $EGREP $GREP \
+ $GUNZIP $GZIP $LS $MV $RM $SED $TAR $TR $DIFF $FIND $MD5SUM \
+ $MYISAMCHK $MYSQL $MYSQLADMIN $MYSQLDUMP $MYTHSHUTDOWN \
+ $SORT $WC $SV
+
+#require file+r "$DROP_SQL"
+
+require dir+r+w+x /tmp "$BACKUP_DIR" "$DATABASE_DIR"
play_sound () {
($PLAYER $SOUNDS/$1 >& /dev/null)&
@@ -56,26 +100,26 @@ play_sound () {
# Filter against an exclude list like the black list or the ignore list above
filter_list () {
- /bin/grep -vxF "$*" |
- /usr/bin/sort -u
+ $GREP -vxF "$*" |
+ $SORT -u
}
# Some people just can't read or follow directions... :-/
# This should track the directory names in the default backup list above
# We also use this to short circuit a certain incredibly dumb stunt
filter_redundant () {
- filter_list "$(echo $BACKUP_LIST ./myth | /usr/bin/tr -s ' ' '\n')" |
- /bin/egrep -v '^\./(root|home|etc|myth)/' |
- /usr/bin/sort -u
+ filter_list "$($TR -s ' ' '\n' <<<"$BACKUP_LIST ./myth")" |
+ $EGREP -v '^\./(root|home|etc|myth)/' |
+ $SORT -u
}
get_extras () {
# One entry per line, and normalize the prefix
- /usr/bin/tr ' ' '\n' <"$1" |
- /usr/bin/awk '/^$/ {next}
- /^\.\// {print $0 ; next}
- /^\// {print "." $0 ; next}
- { print "./" $0}'
+ $TR ' ' '\n' <"$1" |
+ $AWK '/^$/ {next}
+ /^\.\// {print $0 ; next}
+ /^\// {print "." $0 ; next}
+ { print "./" $0}'
}
[ -f "$BACKUP_EXTRAS" ] &&
@@ -101,10 +145,10 @@ esac
shrink () {
case "$COMPRESSION" in
.gz)
- /bin/gzip -9 "$@"
+ $GZIP -9 "$@"
;;
.bz2)
- /bin/bzip2 -9 "$@"
+ $BZIP2 -9 "$@"
;;
*)
;;
@@ -114,13 +158,13 @@ shrink () {
expand () {
case "$*" in
*.gz)
- /bin/gunzip "$@"
+ $GUNZIP "$@"
;;
*.bz2)
- /bin/bunzip2 "$@"
+ $BUNZIP2 "$@"
;;
-c\ *)
- /bin/cat $2 /dev/null
+ $CAT $2 /dev/null
;;
-t\ *)
return 0
@@ -133,8 +177,8 @@ expand () {
}
single_format () {
- candidates=$(/bin/ls -1 "$1.gz" "$1.bz2" "$1" 2>/dev/null)
- case $(echo "$candidates" | /usr/bin/wc -l) in
+ candidates=$($LS -1 "$1.gz" "$1.bz2" "$1" 2>/dev/null)
+ case $($WC -l <<<"$candidates") in
1) return 0 # One is good!
;;
0) echo "Error, no $1 found!"
@@ -161,10 +205,10 @@ backup_roller () { # Gets the rollover sequence to use.
for i in "$@" ; do
for c in .gz .bz2 "" ; do
for f in $BACKUP_SQL $BACKUP_TAR ; do
- /bin/rm -f $f$c$prev_i
+ $RM -f $f$c$prev_i
if [ -f "$f$c$i" ] ; then
echo "Moving $f$c$i to $f$c$prev_i"
- /bin/mv -f $f$c$i $f$c$prev_i
+ $MV -f $f$c$i $f$c$prev_i
fi
done
done
@@ -174,17 +218,17 @@ backup_roller () { # Gets the rollover sequence to use.
# Given "subset A B" return true if is A a subset of B
subset () {
- cnt=$(/usr/bin/diff $1 $2 | /bin/grep '^<' | /usr/bin/wc -l)
+ cnt=$($DIFF $1 $2 | $GREP '^<' | $WC -l)
[ "$cnt" -eq 0 ] && return 0
- /usr/bin/diff $1 $2
+ $DIFF $1 $2
}
mysql_cmd () {
- /usr/bin/mysql -u root $DATABASE -sBe "$*"
+ $MYSQL -u root $DATABASE -sBe "$*"
}
mysql_stdin () {
- /usr/bin/mysql -u root $DATABASE -sB
+ $MYSQL -u root $DATABASE -sB
}
check_files () {
@@ -205,14 +249,14 @@ check_files () {
echo "Generating a list of the backup contents..."
{
expand -c $BACKUP_TAR$c |
- /bin/tar tf - $OBJECT_LIST $EXCLUSION |
- /bin/sed '/\/$/s///' |
+ $TAR tf - $OBJECT_LIST $EXCLUSION |
+ $SED '/\/$/s///' |
filter_list "$IGNORE_LIST" >$SAVED_FILES
- } 2>&1 | /bin/sed -e '/Error exit delayed from previous errors/d'
+ } 2>&1 | $SED -e '/Error exit delayed from previous errors/d'
echo "Generating a list of the directory contents..."
cd /
- /usr/bin/find $OBJECT_LIST \( -type d -or -type f -or -type l \) -print |
+ $FIND $OBJECT_LIST \( -type d -or -type f -or -type l \) -print |
filter_list "$IGNORE_LIST" >$LIVE_FILES
echo "Comparing directory versus backup contents..."
@@ -224,11 +268,11 @@ check_files () {
subset $SAVED_FILES $LIVE_FILES
;;
*)
- /usr/bin/diff $LIVE_FILES $SAVED_FILES
+ $DIFF $LIVE_FILES $SAVED_FILES
;;
esac
FILE_STATUS=$?
- /bin/rm $LIVE_FILES $SAVED_FILES
+ $RM $LIVE_FILES $SAVED_FILES
if [ $FILE_STATUS -eq 0 ] ; then
echo "Live and saved file lists match."
else
@@ -240,11 +284,11 @@ check_files () {
has_records () {
filename="$1"
description="$2"
- if [ $(/usr/bin/wc -l < "$filename") -eq 0 ] ; then
+ if [ $($WC -l < "$filename") -eq 0 ] ; then
echo "Warning, could not get record counts from $description!"
return 1
fi
- if [ $(/usr/bin/awk '{cnt+=$2} END {print cnt}' < "$filename") -eq 0 ] ; then
+ if [ $($AWK '{cnt+=$2} END {print cnt}' < "$filename") -eq 0 ] ; then
echo "Warning, total record count from $description is zero!"
return 1
fi
@@ -267,22 +311,22 @@ check_tables () {
echo "Generating a list of tables and record counts in the DB dump..."
expand -c "$BACKUP_SQL$c" |
- /usr/bin/awk '/CREATE TABLE/ { tbl = $3; gsub("`","",tbl); records[tbl] = 0; } \
+ $AWK '/CREATE TABLE/ { tbl = $3; gsub("`","",tbl); records[tbl] = 0; } \
/INSERT INTO/ { tbl = $3; gsub("`","",tbl); \
n = split(substr($0,index($0,"VALUES (")+7),vals,"\\),\\("); \
records[tbl] += n; } \
END { for (tbl in records) print tbl, records[tbl]; }' |
- /bin/sed 's/mythlog [0-9]*/mythlog 0/' |
- /usr/bin/sort >$SAVED_TABLES
+ $SED 's/mythlog [0-9]*/mythlog 0/' |
+ $SORT >$SAVED_TABLES
has_records "$SAVED_TABLES" "DB dump" || return 1
echo "Generating a list of tables and record counts in the live DB..."
for tbl in $(mysql_cmd "show tables") ; do
mysql_cmd "select '$tbl', count(*) from $tbl"
done |
- /usr/bin/tr -s '\t' ' ' |
- /bin/sed 's/mythlog [0-9]*/mythlog 0/' |
- /usr/bin/sort >$LIVE_TABLES
+ $TR -s '\t' ' ' |
+ $SED 's/mythlog [0-9]*/mythlog 0/' |
+ $SORT >$LIVE_TABLES
has_records "$LIVE_TABLES" "live DB" || return 1
echo "Comparing live versus saved tables..."
@@ -291,11 +335,11 @@ check_tables () {
subset $SAVED_TABLES $LIVE_TABLES
;;
*) # backup must exactly match the database
- /usr/bin/diff $LIVE_TABLES $SAVED_TABLES
+ $DIFF $LIVE_TABLES $SAVED_TABLES
;;
esac
TABLE_STATUS=$?
- /bin/rm $LIVE_TABLES $SAVED_TABLES
+ $RM $LIVE_TABLES $SAVED_TABLES
if [ $TABLE_STATUS -eq 0 ] ; then
echo "Live and saved table lists match."
else
@@ -314,4 +358,13 @@ check_files_and_tables () {
return $STATUS
}
+stop_mysqld () { $SV stop mysql ; }
+start_mysqld () { $SV start mysql ; }
+
+stop_mythbackend () { $SV stop mythbackend ; }
+start_mythbackend () { $SV start mythbackend ; }
+
+lock_myth () { $MYTHSHUTDOWN --lock ; }
+unlock_myth () { $MYTHSHUTDOWN --unlock ; }
+
true # Make sure that this shows success
diff --git a/abs/core-testing/LinHES-system/bin/checkbackup b/abs/core-testing/LinHES-system/bin/checkbackup
index 129e5ff..b6d8587 100755
--- a/abs/core-testing/LinHES-system/bin/checkbackup
+++ b/abs/core-testing/LinHES-system/bin/checkbackup
@@ -1,7 +1,7 @@
#!/bin/bash
#----------------------------------------------------------------------------
-. $LinHES_ROOT/bin/backupcommon || {
+. /usr/LH/bin/backupcommon || {
echo 1>&2 "Can not load common settings!"
exit 1
}
diff --git a/abs/core-testing/LinHES-system/bin/checkrestore b/abs/core-testing/LinHES-system/bin/checkrestore
index 73eb6bc..ef0360c 100755
--- a/abs/core-testing/LinHES-system/bin/checkrestore
+++ b/abs/core-testing/LinHES-system/bin/checkrestore
@@ -1,7 +1,7 @@
#!/bin/bash
#----------------------------------------------------------------------------
-. $LinHES_ROOT/bin/backupcommon || {
+. /usr/LH/bin/backupcommon || {
echo 1>&2 "Can not load common settings!"
exit 1
}
diff --git a/abs/core-testing/LinHES-system/bin/library.sh b/abs/core-testing/LinHES-system/bin/library.sh
new file mode 100755
index 0000000..2049de3
--- /dev/null
+++ b/abs/core-testing/LinHES-system/bin/library.sh
@@ -0,0 +1,164 @@
+msg () { # A status reporting function
+ [ "${VERBOSE:-0}" -gt 0 ] && echo "$*"
+}
+
+error () { # An error reporting function
+ echo 1>&2 "$*"
+}
+
+fatal () { # Report an error and exit with a failure code
+ error "$*"
+ exit 1
+}
+
+# The only non builtin this uses is tr...
+require () { # Check prerequisites
+ e=0
+ props="$1" ; shift
+ for obj in "$@" ; do
+ [ -z "$obj" ] && continue # Too late to do anything itelligent...
+ problems=""
+ for prop in $(/bin/tr '+,' ' ' <<<"$props") ; do
+ case "$prop" in
+ e|exists) # kind of useless...
+ [ -e "$obj" ] || problems="$problems, does not exist" ;;
+ f|file)
+ [ -f "$obj" ] || problems="$problems, is not a file" ;;
+ d|dir)
+ [ -d "$obj" ] || problems="$problems, is not a directory" ;;
+ l|symlink)
+ [ -L "$obj" ] || problems="$problems, is not a symlink" ;;
+ nosymlink)
+ [ -L "$obj" ] && problems="$problems, is a symlink" ;;
+ r|readable)
+ [ -r "$obj" ] || problems="$problems, is not readable" ;;
+ w|writable)
+ [ -w "$obj" ] || problems="$problems, is not writable" ;;
+ x|executable)
+ [ -x "$obj" ] || problems="$problems, is not executable" ;;
+ *)
+ fatal "Programmer error, unknown property: '$prop'" ;;
+ esac
+ done
+ if [ -n "$problems" ] ; then
+ error "Error: '$obj'$problems."
+ e=1
+ fi
+ done
+ [ "$e" -ne 0 ] && fatal "Errors noted above are fatal."
+}
+
+require file+r+x /bin/bash /bin/grep /bin/rm /bin/tr \
+ /usr/bin/basename /usr/bin/env \
+ /usr/bin/mysql /usr/bin/sort
+
+if [ -n "$DEBUG" ] ; then
+ for debug_opt in $(/bin/tr ',' ' ' <<<"$DEBUG") ; do
+ echo '============================================================'
+ echo "==== $debug_opt"
+
+ # Note that the order you specifiy these debug options in matters.
+ # I recommend always listing log first. For example:
+ # export DEBUG=log,env,set,trace
+ case "$debug_opt" in
+ env) /usr/bin/env | /usr/bin/sort ;;
+ set) set ;;
+ trace) set -vx ;;
+ log) logfile="/tmp/$(/usr/bin/basename $0).$$.debug"
+ /bin/rm -f "$logfile" # Try to avoid privilege escalation bugs
+ echo "Redirecting stdout and stderr to '$logfile'"
+ exec >"$logfile" 2>&1 ;;
+ *) error "Unknown debug option '$debug_opt'" ;;
+ esac
+ done
+ echo '============================================================'
+fi
+
+must_be_root () { # For things which must be run as root
+ [ $(/usr/bin/id -u) -ne 0 ] && fatal "You must run this script as root!"
+}
+
+must_be_mythtv () { # For things which must be run as mythtv (su if possible)
+ case $(/usr/bin/id -nu) in
+ mythtv) ;; # Continue
+ root) /bin/su - mythtv -c "$0 $*" ; exit $? ;;
+ *) fatal "You must run this script at mythtv or root!" ;;
+ esac
+}
+
+# Use a variable so you can override it.
+DATABASE="mythconverg"
+
+mysql_cmd () { # Execute SQL from the command line
+ /usr/bin/mysql -u root "$DATABASE" -sBe "$*"
+}
+
+mysql_stdin () { # Execute SQL from stdin
+ /usr/bin/mysql -u root "$DATABASE" -sB
+}
+
+machine_clause () { # Helper function
+ if [ -z "$1" ] ; then
+ echo "(hostname = '' or hostname is null)"
+ else
+ echo "hostname = '$1'"
+ fi
+}
+
+get_all_setting_names () { # List setting names
+ case "$#" in
+ 0) MACHINE_CLAUSE="" ;;
+ 1) MACHINE_CLAUSE="where $(machine_clause "$1")" ;;
+ *) fatal "Programmer error, get_all_names must be passed 0 or 1 args, got $#" ;;
+ esac
+ mysql_cmd "select distinct value from settings $MACHINE_CLAUSE order by value"
+}
+
+get_all_setting_values () { # List settings
+ case "$#" in
+ 0) MACHINE_CLAUSE="" ;;
+ 1) MACHINE_CLAUSE="where $(machine_clause "$1")" ;;
+ *) fatal "Programmer error, get_all_values must be passed 0 or 1 args, got $#" ;;
+ esac
+ mysql_cmd "select value, data, hostname from settings $MACHINE_CLAUSE order by hostname, value, data"
+}
+
+get_setting_value () { # Get the data for a setting (may return multiples!)
+ case "$#" in
+ 1) MACHINE_CLAUSE="" ;;
+ 2) MACHINE_CLAUSE="and $(machine_clause "$2")" ;;
+ *) fatal "Programmer error, get_value must be passed 1 or 2 args, got $#" ;;
+ esac
+ mysql_cmd "select data from settings where value = '$1' $MACHINE_CLAUSE"
+}
+
+set_setting_value () { # Insert or update aome setting
+ case "$#" in
+ 2) RECORD_CNT=$(get_value "$1" | wc -l) ;;
+ 3) RECORD_CNT=$(get_value "$1" "$3" | wc -l) ;;
+ *) fatal "Programmer error, set_value must be passed 2 or 3 args, got $#" ;;
+ esac
+ MACHINE_CLAUSE=""
+ if [ "$RECORD_CNT" -eq 0 ] ; then
+ [ -n "$3" ] && MACHINE_CLAUSE=", $(machine_clause "$3")"
+ mysql_cmd "insert into settings set value = '$1', data = '$2' $MACHINE_CLAUSE"
+ else
+ [ "$#" -eq 3 ] && MACHINE_CLAUSE="and $(machine_clause "$3")"
+ mysql_cmd "update settings set data = '$2' where value = '$1' $MACHINE_CLAUSE"
+ fi
+}
+
+delete_setting_value () { # Totally remove some setting
+ case "$#" in
+ 1) MACHINE_CLAUSE="" ;;
+ 2) MACHINE_CLAUSE="and $(machine_clause "$2")" ;;
+ *) fatal "Programmer error, get_value must be passed 1 or 2 args, got $#" ;;
+ esac
+ mysql_cmd "delete from settings where value = '$1' $MACHINE_CLAUSE"
+}
+
+# Filter against a newline seperated exclude list
+filter_list () {
+ /bin/grep -vxF "$*" |
+ /usr/bin/sort -u
+}
diff --git a/abs/core-testing/LinHES-system/bin/mythbackup b/abs/core-testing/LinHES-system/bin/mythbackup
index dfba611..d3cc4e8 100755
--- a/abs/core-testing/LinHES-system/bin/mythbackup
+++ b/abs/core-testing/LinHES-system/bin/mythbackup
@@ -1,18 +1,18 @@
#!/bin/bash
#----------------------------------------------------------------------------
-. $LinHES_ROOT/bin/backupcommon || {
+. /usr/LH/bin/backupcommon || {
echo 1>&2 "Can not load common settings!"
exit 1
}
#----------------------------------------------------------------------------
+# Prevent mythshutdown from shutting down the system in the middle...
+lock_myth
+
# Play a sound to let you know I'm starting.
play_sound init.wav
-# Prevent mythshutdown from shutting down the system in the middle...
-/usr/bin/mythshutdown --lock
-
# Keep a chain of recent backups,
echo "Starting rollover of old backups, this may take a while..."
[ -f "$BACKUP_SQL" ] && shrink $BACKUP_SQL
@@ -23,16 +23,16 @@ echo "Rollover completed."
# Start with the database backup, first we make sure it's healthy, and
# then we can dump it.
# Doing this while the backend is active would be BAD.
-/etc/init.d/mythtv-backend stop
+stop_mythbackend
# Stop, check, and fix $DATABASE db to ensure clean copy, then restart it.
-/etc/init.d/mysql stop
+stop_mysqld
cd $DATABASE_DIR
-/usr/bin/myisamchk -f *.MYI
-/etc/init.d/mysql stop ; /etc/init.d/mysql start
+$MYISAMCHK -f *.MYI
+start_mysqld
# Dumps the $DATABASE database
-/usr/bin/mysqldump -c -u root $DATABASE > $BACKUP_SQL
+$MYSQLDUMP -c -u root $DATABASE > $BACKUP_SQL
shrink $BACKUP_SQL
# Now to backup the other files, no fooling around, grab everything in the
@@ -41,13 +41,13 @@ shrink $BACKUP_SQL
# gather all the things in the list into a nice tidy bundle
cd /
-/bin/tar cvf $BACKUP_TAR $BACKUP_LIST 2>&1 |
- /bin/sed -e '/Error exit delayed from previous errors/d'
+$TAR cvf $BACKUP_TAR $BACKUP_LIST 2>&1 |
+ $SED -e '/Error exit delayed from previous errors/d'
shrink $BACKUP_TAR
# If you can't read this you've got no business restoring from it anyway.
-/bin/chown root:root $BACKUP_TAR* $BACKUP_SQL*
-/bin/chmod go-rwx $BACKUP_TAR* $BACKUP_SQL*
+$CHOWN root:root $BACKUP_TAR* $BACKUP_SQL*
+$CHMOD go-rwx $BACKUP_TAR* $BACKUP_SQL*
echo "Sanity checking your backup..."
play_sound testing.wav
@@ -63,9 +63,9 @@ else
fi
# Now we can restart the backend.
-/etc/init.d/mythtv-backend stop ; /etc/init.d/mythtv-backend start
+start_mythbackend
# Unlock the system again...
-/usr/bin/mythshutdown --unlock
+unlock_myth
exit $STATUS
diff --git a/abs/core-testing/LinHES-system/bin/mythrestore b/abs/core-testing/LinHES-system/bin/mythrestore
index c13d357..7fce371 100755
--- a/abs/core-testing/LinHES-system/bin/mythrestore
+++ b/abs/core-testing/LinHES-system/bin/mythrestore
@@ -1,10 +1,7 @@
#!/bin/bash
-# Let's prevent mythshutdown from shutting down the system.
-/usr/bin/mythshutdown --lock
-
#----------------------------------------------------------------------------
-. $LinHES_ROOT/bin/backupcommon || {
+. /usr/LH/bin/backupcommon || {
echo 1>&2 "Can not load common settings!"
exit 1
}
@@ -18,7 +15,7 @@ do_file_updates() { # A function because we need to do this in two places
do_db_updates() {
# We need to redo this since we just restored the old settings...
- /usr/bin/mythshutdown --lock
+ lock_myth
# This is gross, but makes sure that the lock count has a sane value...
mysql_cmd "update settings set data = '1' where value = 'MythShutdownLock'"
@@ -37,11 +34,14 @@ do_db_updates() {
mysql_cmd "drop table mythweb_sessions" >/dev/null 2>&1
}
+# Let's prevent mythshutdown from shutting down the system.
+lock_myth
+
# Play a sound to let you know I'm starting.
play_sound restore.wav
# Doing this while the backend is active could be BAD.
-/etc/init.d/mythtv-backend stop
+stop_mythbackend
# If the standard backup file exists we try to restore the files based
# on our restore list.
@@ -49,8 +49,8 @@ if compression=$(compression_type "$BACKUP_TAR") ; then
echo "Starting the restore of files..."
cd /
expand -c $BACKUP_TAR$compression |
- /bin/tar xpvf - $RESTORE_LIST $EXCLUSION 2>&1 |
- /bin/sed -e '/Error exit delayed from previous errors/d'
+ $TAR xpvf - $RESTORE_LIST $EXCLUSION 2>&1 |
+ $SED -e '/Error exit delayed from previous errors/d'
echo "Completed the restore of files."
fi
@@ -58,9 +58,9 @@ fi
if compression=$(compression_type "$BACKUP_SQL") ; then
echo "Starting the DB restore, this can take a while..."
echo "Clearing out the existing skeleton..."
- mysql_stdin < $DROP_SQL
+ #mysql_stdin < $DROP_SQL
echo "Recreating the db..."
- /usr/bin/mysqladmin -u root create $DATABASE
+ $MYSQLADMIN -u root create $DATABASE
echo "Restoring the data (long)..."
expand -c $BACKUP_SQL$compression | mysql_stdin
echo "Doing any needed db updates..."
@@ -87,6 +87,6 @@ do_db_updates
do_file_updates
# Now it's more or less safe to restart the backend.
-/etc/init.d/mythtv-backend stop ; /etc/init.d/mythtv-backend start
+start_mythbackend
exit $STATUS
diff --git a/abs/core-testing/LinHES-system/bin/rollback.sh b/abs/core-testing/LinHES-system/bin/rollback.sh
new file mode 100755
index 0000000..12897da
--- /dev/null
+++ b/abs/core-testing/LinHES-system/bin/rollback.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+#----------------------------------------------------------------------------
+. /usr/LH/bin/backupcommon || {
+ echo 1>&2 "Can not load common settings!"
+ exit 1
+}
+#----------------------------------------------------------------------------
+
+require file+r+x $MYTHSHUTDOWN
+
+# Prevent mythshutdown from shutting down the system in the middle...
+lock_myth
+
+echo "Starting rollback of old backups"
+backup_roller '' .1 .2 .3 .4 .5 .6 .7 .8 .9 .10 .11 .12 .13 .14 .15 .16 .17 .18 .19
+echo "Rollback completed."
+
+# Unlock the system again...
+unlock_myth