diff options
author | Cecil Hugh Watson <knoppmyth@gmail.com> | 2009-09-26 01:57:08 (GMT) |
---|---|---|
committer | Cecil Hugh Watson <knoppmyth@gmail.com> | 2009-09-26 01:57:08 (GMT) |
commit | 7b29169fff9e7c624890c5edffe85def8a293136 (patch) | |
tree | 47753889faa3a2063b66d1c7e7681e703eb1b39a /abs/core/LinHES-system/bin/mythbackup | |
parent | c491dea779dac29afff3578bf8245943817c2339 (diff) | |
download | linhes_pkgbuild-7b29169fff9e7c624890c5edffe85def8a293136.zip linhes_pkgbuild-7b29169fff9e7c624890c5edffe85def8a293136.tar.gz linhes_pkgbuild-7b29169fff9e7c624890c5edffe85def8a293136.tar.bz2 |
LinHES 6.01.00
Diffstat (limited to 'abs/core/LinHES-system/bin/mythbackup')
-rwxr-xr-x | abs/core/LinHES-system/bin/mythbackup | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/abs/core/LinHES-system/bin/mythbackup b/abs/core/LinHES-system/bin/mythbackup new file mode 100755 index 0000000..d0d028d --- /dev/null +++ b/abs/core/LinHES-system/bin/mythbackup @@ -0,0 +1,71 @@ +#!/bin/bash + +#---------------------------------------------------------------------------- +. /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 + +# Keep a chain of recent backups, +echo "Starting rollover of old backups, this may take a while..." +[ -f "$BACKUP_SQL" ] && shrink $BACKUP_SQL +[ -f "$BACKUP_TAR" ] && shrink $BACKUP_TAR +backup_roller .19 .18 .17 .16 .15 .14 .13 .12 .11 .10 .9 .8 .7 .6 .5 .4 .3 .2 .1 '' +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. +stop_mythbackend + +# Stop, check, and fix $DATABASE db to ensure clean copy, then restart it. +stop_mysqld +cd $DATABASE_DIR +$MYISAMCHK -f *.MYI +start_mysqld + +# Dumps the $DATABASE database +$MYSQLDUMP -v -c -u root $DATABASE > $BACKUP_SQL +shrink $BACKUP_SQL + +# 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 / +$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. +$CHOWN root:root $BACKUP_TAR* $BACKUP_SQL* +$CHMOD go-rwx $BACKUP_TAR* $BACKUP_SQL* + +echo "Sanity checking your backup..." +play_sound testing.wav +# Play a sound to let you know the outcome. +if check_files_and_tables $BACKUP_LIST ; then + echo "Backup passes all checks." + play_sound complete.wav + STATUS=0 +else + echo "The backup is bad or already out of date!" + play_sound fail.wav + STATUS=1 +fi + +# Now we can restart the backend. +start_mythbackend + +# Unlock the system again... +unlock_myth + +exit $STATUS |