I've been tinkering with it a bit. I've been modifying the included mythbackup/mythrestore scripts to perform a backup and save it on the MBE. I've only got thru the backup scripts. I have yet to tinker with restore. Here's what I have for backup...
BEWARE UNTESTED CODE! USE AT YOUR OWN RISK!
mythbackup-fe
Code:
#!/bin/bash
set -vx
#----------------------------------------------------------------------------
#. /usr/local/bin/backupcommon || {
. /usr/local/bin/backupcommon-fe || {
echo "Can not find common settings!"
exit 1
}
#----------------------------------------------------------------------------
# Play a sound to let you know I'm starting.
play_sound init.wav
# Keep a chain of recent backups,
echo "Starting rollover of old backups, this may take a while..."
[ -f "$BACKUP_TAR" ] && shrink $BACKUP_TAR
backup_roller .9 .8 .7 .6 .5 .4 .3 .2 .1 ''
echo "Rollover completed."
# Now to backup the other files, no fooling around, grab everything in the
# list because you never know what you'll want, and we can always get clever
# about what to restore later...
# gather all the things in the list into a nice tidy bundle
cd /
/bin/tar cvf $BACKUP_TAR $BACKUP_LIST
shrink $BACKUP_TAR
# If you can't read this you've got no business restoring from it anyway.
/bin/chown root:root $BACKUP_TAR*
/bin/chmod go-rwx $BACKUP_TAR*
echo "Sanity checking your backup..."
play_sound testing.wav
# Play a sound to let you know the outcome.
if check_files $BACKUP_LIST ; then
echo "Backup passes all checks."
play_sound complete.wav
exit 0
else
echo "The backup is bad or already out of date!"
play_sound fail.wav
exit 1
fi
backupcommon-fe
Code:
#!/bin/bash
set -vx
#----------------------------------------------------------------------------
BACKUP_LIST="./root ./home ./etc"
RESTORE_LIST="./root ./home ./etc/mythtv/modules ./etc/lirc ./etc/X11/xorg.conf ./etc/asound.conf ./etc/default/aumix ./etc/$
IGNORE_LIST='./home/mythtv/.upgrade
./home/mythtv/.configure
./home/mythtv/.newcard
./root/mythstreamweb.tar
./home/mythtv/.Xauthority
./root/.Xauthority'
BACKUP_DIR="/myth/backup/rfe-2"
BACKUP_EXTRAS="$BACKUP_DIR/backup-rfe-2.list"
RESTORE_EXTRAS="$BACKUP_DIR/restore-rfe-2.list"
BACKUP_TAR="$BACKUP_DIR/savedfiles-rfe-2.tar"
UPDATE_FILES="/usr/local/bin/restore_fixups.sh"
COMPRESSION=".gz"
SOUNDS="/usr/share/sounds"
PLAYER="/usr/bin/aplay"
#----------------------------------------------------------------------------
play_sound () {
($PLAYER $SOUNDS/$1 >& /dev/null)&
}
get_extras () {
extras=""
for extra in $(/bin/cat $1); do
case "$extra" in
./*) extras="$extras $extra" ;;
/*) extras="$extras .$extra" ;;
*) extras="$extras ./$extra" ;;
esac
done
echo "$extras"
}
[ -f "$BACKUP_EXTRAS" ] &&
BACKUP_LIST="$BACKUP_LIST $(get_extras $BACKUP_EXTRAS)"
[ -f "$RESTORE_EXTRAS" ] &&
RESTORE_LIST="$RESTORE_LIST $(get_extras $RESTORE_EXTRAS)"
shrink () {
case "$COMPRESSION" in
.gz)
/bin/gzip -9 "$@"
;;
.bz2)
/bin/bzip2 -9 "$@"
;;
*)
;;
esac
}
expand () {
case "$*" in
*.gz)
/bin/gunzip "$@"
;;
*.bz2)
/bin/bunzip2 "$@"
;;
-c\ *)
/bin/cat $2 /dev/null
;;
-t\ *)
return 0
;;
*)
echo 1>&2 "Error, unknown file type!"
return 1
;;
esac
}
single_format () {
candidates=$(ls -1 "$1.gz" "$1.bz2" "$1" 2>/dev/null)
case $(echo "$candidates" | wc -l) in
1) return 0 # One is good!
;;
0) echo "Error, no $1 found!"
return 1
;;
*) echo "Warning, multiple formats for $1 found!"
echo "Candidates are: $candidates"
;;
esac
}
compression_type () {
for compression in .gz .bz2 "" ; do
if [ -f "$1$compression" ] ; then
echo "$compression"
return 0
fi
done
return 1
}
backup_roller () { # Gets the rollover sequence to use.
prev_i=$1 ; shift
for i in "$@" ; do
for c in .gz .bz2 "" ; do
for f in $BACKUP_TAR ; do
/bin/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
fi
done
done
prev_i="$i"
done
}
# 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" -eq 0 ] && return 0
/usr/bin/diff $1 $2
}
check_files () {
OBJECT_LIST="$*"
LIVE_FILES=/tmp/live_files_$$
SAVED_FILES=/tmp/saved_files_$$
echo "Checking for the existance of the backup tar file..."
single_format "$BACKUP_TAR"
c=$(compression_type "$BACKUP_TAR") ||
{ echo "Error, missing tar file - '$BACKUP_TAR$c'." ; return 1 ; }
echo "Using file $BACKUP_TAR$c"
echo "Backup tar file exists. Checking the compression..."
expand -t $BACKUP_TAR$c ||
{ echo "Error, bad compressed tarball - '$BACKUP_TAR$c'." ; return 1 ; }
echo "Compression looks OK. Checking backup tar file contents..."
echo "Generating a list of the backup contents..."
expand -c $BACKUP_TAR$c | /bin/tar tf - $OBJECT_LIST |
/bin/sed '/\/$/s///' | /bin/grep -vxF "$IGNORE_LIST" | /usr/bin/sort -u >$SAVED_FILES
echo "Generating a list of the directory contents..."
cd /
/usr/bin/find $OBJECT_LIST \( -type d -or -type f -or -type l \) -print |
/bin/grep -vxF "$IGNORE_LIST" | /usr/bin/sort -u >$LIVE_FILES
echo "Comparing directory versus backup contents..."
case $0 in
*backup) # backup must contain everything selected from the directories
subset $LIVE_FILES $SAVED_FILES
;;
*restore) # directories must contain everything selected from the backup
subset $SAVED_FILES $LIVE_FILES
;;
*)
/usr/bin/diff $LIVE_FILES $SAVED_FILES
;;
esac
FILE_STATUS=$?
/bin/rm $LIVE_FILES $SAVED_FILES
if [ $FILE_STATUS -eq 0 ] ; then
echo "Live and saved file lists match."
else
echo "Warning, file lists are not identical!"
fi
return $FILE_STATUS
}
has_records () {
filename="$1"
description="$2"
if [ $(wc -l < "$filename") -eq 0 ] ; then
echo "Warning, could not get record counts from $description!"
return 1
fi
if [ $(awk '{cnt+=$2} END {print cnt}' < "$filename") -eq 0 ] ; then
echo "Warning, total record count from $description is zero!"
return 1
fi
return 0
}
#check_files () {
# STATUS=0
# echo
# check_files "$@" || STATUS=1
# echo
# return $STATUS
#}
true # Make sure that this shows success
The main problem I see with this is that on a KnoppMyth upgrade, your NFS mount to your MBE will not be available. I'm kicking around some ideas in my head about how to deal with that, but if anyone has any suggestions, I welcome them.