3 scriptsdir=$(dirname $0)
5 export PATH=$scriptsdir:$PATH
7 # file locations and other values
8 today=$(date +%Y%m%d%H%M%S)
9 datadir="/var/lib/backups"
10 tmpdir="/dev/shm/backups"
11 currentfiles="$tmpdir/files.db"
12 backupdb="$datadir/backups.db"
13 backups="$tmpdir/backup-list.db"
14 statusfile="$tmpdir/backup-status.txt"
15 isomountdir="/backup/iso-mount"
16 isoimage="/backup/ISOs/$today.iso"
17 restorescript="$scriptsdir/restore.sh"
19 echo "Creating the iso image in $isoimage"
23 # Create filesystem on iso image here
24 dd if=/dev/null of=$isoimage bs=2048k count=0 seek=2220
25 mke2fs -b 2048 -F $isoimage
27 echo "Mounting the iso image"
28 # Mount iso image here
29 mount -t ext2 -o loop $isoimage $isomountdir
35 chmod 600 $currentfiles
36 echo "Running find to get the status of files"
39 findformat="$type %#m %u %g %s %CY%Cm%Cd%CH%CM%CS 0 %p\0"
40 find /home -type $type -printf "$findformat"
44 echo "Determining list of files to backup with lsbackups"
46 # lsbackups expects the current date followed by a null before the list of files
49 } | lsbackups > $backups 2>$statusfile
51 echo "Running rsync to pack the image"
52 rsyncopts="-l -p -t -g -o -0 --files-from=- --stats --progress"
53 cat $backups | rsync $rsyncopts / $isomountdir
55 echo "Copying over database and status file"
56 cp $statusfile $backupdb $restorescript $isomountdir
58 mount -o remount -o ro $isomountdir
62 md5sum $isoimage > $isoimage.md5sum
65 # dvdrecord [-dummy] [-overburn] -dao speed=8 dev=[ATAPI:]?,?,? iso-image.iso
68 cat $statusfile | mailx -s "DVD Image available on ball, burn it!" carl@ecbaldwin.net