# file locations and other values
today=$(date +%Y%m%d%H%M%S)
+mailto='carl@ecbaldwin.net'
datadir="/var/lib/backups"
tmpdir="/dev/shm/backups"
currentfiles="$tmpdir/files.db"
backups="$tmpdir/backup-list.db"
statusfile="$tmpdir/backup-status.txt"
isomountdir="/backup/iso-mount"
-isoimage="/backup/ISOs/$today.iso"
+isoimage="/backup/ISOs/$today.img"
restorescript="$scriptsdir/restore.sh"
echo "Creating the iso image in $isoimage"
echo "Copying over database and status file"
cp $statusfile $backupdb $restorescript $isomountdir
-mount -o remount -o ro $isomountdir
-# Should be
-# umount $isomountdir
+echo "Unmounting image"
+umount $isomountdir
-md5sum $isoimage > $isoimage.md5sum
+echo "Calculating md5sum for image"
+md5sum $isoimage | awk '{print$1}' > $isoimage.md5sum
# Burn the iso image
-# dvdrecord [-dummy] [-overburn] -dao speed=8 dev=[ATAPI:]?,?,? iso-image.iso
+echo "Burn the image to a DVD"
+if cdrecord-wrapper.sh -dao speed=8 dev=ATA:1,0,0 $isoimage; then
+ md5sum_file=$(tempfile)
+ dd if=/dev/hdc bs=2048k count=2220 | md5sum | awk '{print$1}' > $md5sum_file
+ if ! cmp $md5sum_file $isoimage.md5sum; then
+ echo "Failed" | mailx -s "DVD md5sum doesn't match image file!!!" $mailto
+ exit 1
+ fi
+else
+ echo "Failed" | mailx -s "DVD burning failed!!!" $mailto
+ exit 1
+fi
# Email me
-cat $statusfile | mailx -s "DVD Image available on ball, burn it!" carl@ecbaldwin.net
+cat $statusfile | mailx -s "DVD burned. File it as $today" $mailto