8 [ -n "$3" ] && mountdir=$3
10 [ -z "$mountdir" ] && err '$mountdir must be set'
11 [ -z "$rundir" ] && err '$rundir must be set'
13 export PATH=${rundir%%/}:/bin:/usr/bin:/sbin:/usr/sbin:/sw/bin
15 if [ ! -z "$1" -o ! -d "$2" ]; then
17 Usage: $0 <source-dir> <relocate-dir> [<mnt-dir>]
18 source-dir - directory on backup disks to restore from (relative to $mountdir)
19 relocate-dir - base directory to restore files to (usually /)
20 mnt-dir - directory where backup disk is mounted (optional)
23 % $0 / / /mnt/cdrom # Restore everything from disks (explicitly specifying dvd mount point.)
24 % $0 / / # Restore everything from disks
25 % $0 /home / # Restore only files under /home on disks to /home on the system
26 % $0 /home /home # Restore files under /home on disks to /home/home on the system (probably not what you want.)
30 device=$(mount | grep "on ${mountdir%%/} " | awk '{print$1}')
32 [ -z "$device" ] && err "Cannot determine cdrom device"
34 cp ${mountdir%%/}/backups.db ${mountdir%%/}/backup-status.txt $rundir
35 dbfile=${rundir%%/}/backups.db
37 dates=$(cat $dbfile | list-dates.sh)
39 for date in $dates; do
43 [ $? != 0 ] && err "Cannot eject the disk. Drive is busy. Run lsof $mountdir to see why."
44 echo "Please insert backup disk: $date"
45 echo "Press Enter to continue"
50 mount -t ext2 $device ${mountdir%%/}
52 if grep -q $date ${mountdir%%/}/backup-status.txt; then
55 echo "This doesn't seem to be the right disk."
59 rsyncopts="-W -H -S -l -p -t -g -o -0 --files-from=- --stats --progress"
60 cat $dbfile | files-from-date.sh $date | grep -z -Z -e "^${1%/}/" | rsync $rsyncopts ${mountdir%%/}/ ${2%%/}/