I'm sure many of you are like me: afraid that if I make a change such as installing a new ivtv driver, or even upgrading to the latest KnoppMyth release, that I'll break something and have the family impatiently standing over my shoulder until I fix it...
tjc's new backup/restore tools in R5C7 will provide a recovery mechanism for many cases.
Here's something that will provide an extra safety net for more extreme cases. The following script will create a backup of the primary KnoppMyth partition, which can be used as an emergency recovery vehicle when things REALLY go astray.
Code:
#! /bin/bash
# Utility to back up the primary KnoppMyth partition
# Submitted by Ken Scales (ashtonp)
# Mostly a wrapper around a tar command to back up a single partition.
if test $(id -u) != 0; then
echo "Error: You must be root to run this script!"
exit
fi
DATE=`/bin/date +%Y%B%d`
echo ""
echo "Note: disregard any messages about \"different filesystem\" or"
echo " \"socket\" not being archived. These are intentional."
sleep 3
echo ""
echo "Starting backup for file system partition \"/\"..."
echo ""
echo " Stopping mythtv-backend..."
/etc/init.d/mythtv-backend stop
echo " Stopping mysql..."
/etc/init.d/mysql stop
# For an uncompressed archive, uncomment the next 2 lines, and comment the 2
# similar lines following them. Also see similar changes near end of script.
#echo "Executing: /bin/tar clvf /myth/backup/slash_$DATE.tar --exclude=/var/log / 2>&1 > /myth/backup/tar_clvf_slash_$DATE.log"
# /bin/tar clvf /myth/backup/slash_$DATE.tar --exclude=/var/log / 2>&1 > /myth/backup/tar_clvf_slash_$DATE.log
echo "Executing: /bin/tar czlvf /myth/backup/slash_$DATE.tgz --exclude=/var/log / 2>&1 > /myth/backup/tar_czlvf_slash_$DATE.log"
/bin/tar czlvf /myth/backup/slash_$DATE.tgz --exclude=/var/log / 2>&1 > /myth/backup/tar_czlvf_slash_$DATE.log
echo ""
echo " \"tar\" file creation complete."
echo ""
echo " Restarting mysql..."
/etc/init.d/mysql start
echo " Restarting mythtv-backend..."
/etc/init.d/mythtv-backend start
echo ""
# For uncompressed archive, uncomment the next 2 lines, and comment the 2
# similar lines following them. Also see similar changes earlier in script.
#echo "Backup was created as: \"/myth/backup/slash_$DATE.tar\"."
#echo " Logfile is in: \"/myth/backup/tar_clvf_slash_$DATE.log\"."
echo "Backup was created as: \"/myth/backup/slash_$DATE.tgz\"."
echo " Logfile is in: \"/myth/backup/tar_czlvf_slash_$DATE.log\"."
echo ""
echo "File system backup for partition \"/\" is complete."
echo ""
Paste the above code into a file (say "/usr/local/bin/backup_slash_partition", then:
Code:
chmod 755 /usr/local/bin/backup_slash_partition
This script temporarily shuts off both mythtv-backend and mysql, so make sure that no events are scheduled before you run it.
To run the script, as "root":
Code:
/usr/local/bin/backup_slash_partition
This will create a compressed file in /myth/backup containing an image of the main "/" partition (excluding log files and sockets). On my system (AMD 2800+ Athlon; KnoppMyth R5B7) it takes about 5 minutes to execute, and creates a compressed backup of about 900Mb.
Note the backup filename displayed (specifically, "slash_YYYYMonthDD.tgz" -- substitute appropriately below.)
There are several cases where this backup file could be used for recovery, but one might be an unsuccessful upgrade installation. In this case, the steps would (ROUGHLY) be:
Code:
reboot with the KnoppMyth installation CD
select "exit" from the installation menu
umount /dev/hda1
mkfs.ext3 /dev/hda1
mount /dev/hda1 /mnt/hdinstall
mkdir /mnt/myth
mount /dev/hda4 /mnt/myth
# Change the above to reflect where your /myth partition is located (/mnt/hda3 on R5[BC]7 fresh installs)
cd /mnt/hdinstall
tar xzvf /mnt/myth/backup/slash_YYYYMonthDD.tgz
You may also need to update lilo:
Code:
chroot /mnt/hdinstall
lilo
exit
Re-boot, and you should be back to the point where you took your snapshot, including all database and recording info. If your database has been updated since the snapshot was taken, use the standard KnoppMyth Backup/Restore tools (e.g., tjc's toolbox) to recover those changes.
Note: any changes to the /myth directory (e.g., /myth/avimanager, /myth/mythburn, and /myth/nuv2disc) made during a KnoppMyth upgrade/installation will not be undone by this method, and they may need to be re-installed. Also, if you are using LVM for your /myth partition, you will need to do some extra steps that I'm not familiar with.