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