LinHES Forums http://forum.linhes.org/ |
|
MythFrontendBackup? http://forum.linhes.org/viewtopic.php?f=3&t=16512 |
Page 1 of 1 |
Author: | kmkittre [ Fri Sep 14, 2007 12:06 pm ] |
Post subject: | MythFrontendBackup? |
Has anyone written a script for backing up a MythTV frontend-only box? I can manually tar /etc, /root, & /home, but if someone has already written a script, that would be nicer than doing it manually... |
Author: | Too Many Secrets [ Fri Sep 14, 2007 12:11 pm ] |
Post subject: | |
I was thinking about this myself as I'm preparing for the leap to F27 this weekend... |
Author: | kmkittre [ Fri Sep 14, 2007 1:38 pm ] |
Post subject: | |
me too ![]() This message in MythWeb got me to say: "okay it's time": Quote: There's guide data until 2007-09-17 19:00 (3 days). WARNING: is mythfilldatabase running?
Good luck. |
Author: | mihanson [ Fri Sep 14, 2007 1:48 pm ] |
Post subject: | |
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. |
Author: | tjc [ Fri Sep 14, 2007 7:24 pm ] |
Post subject: | |
What did you have to change in backupcommon? Without auditing the code right now I can't think of anything obvious where the file and db stuff isn't separated out... |
Author: | kmkittre [ Mon Sep 17, 2007 1:11 pm ] |
Post subject: | |
Well, I just ended up backing it up manually... It would be nice, though, to have a supported frontend backup that essentially backs up the same as the backend but without backing up the database. |
Author: | cecil [ Wed Sep 19, 2007 8:57 pm ] |
Post subject: | |
How the frell is this a hint or tip? You don't ask for hints or tips, you frelling post them. |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |