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
18 Usage: $(basename $0) <source-dir> <relocate-dir> [<mnt-dir>]
19 source-dir - Directory on backup disks to restore (relative to
21 relocate-dir - Base directory to restore files into (usually /)
22 mnt-dir - Directory where backup disk is mounted (optional)
25 # Restore everything from disks (explicitly specifying dvd mount point.)
26 % $(basename $0) / / /mnt/cdrom
28 # Restore everything from disks
31 # Restore only files under /home on disks to /home on the system
32 % $(basename $0) /home /
34 # Restore files under /home on disks to /home/home on the system
35 # (this is usually not what you want.)
36 % $(basename $0) /home /home
40 device=$(mount | grep "on ${mountdir%/} " | awk '{print$1}')
42 [ -z "$device" ] && err "Cannot determine cdrom device"
44 cp ${mountdir%/}/backups.db ${mountdir%/}/backup-status.txt $rundir
45 dbfile=${rundir%/}/backups.db
47 dates=$(cat $dbfile | list-dates.sh)
49 for date in $dates; do
51 # Check to see if files are actually needed from the current disk before requesting it.
52 cat $dbfile | files-from-date.sh $date | grep -z -Z -e "^${1%/}/" > $filelist
53 if [ -s $filelist ]; then
57 [ $? != 0 ] && err "Cannot eject the disk. Drive is busy. Run lsof $mountdir to see why."
58 echo "Please insert backup disk: $date"
59 echo "Press Enter to continue"
64 mount -t ext2 $device ${mountdir%/}
66 if grep -q $date ${mountdir%/}/backup-status.txt; then
69 echo "This doesn't seem to be the right disk."
73 rsyncopts="-W -H -S -l -p -t -g -o -0 --files-from=- --stats --progress"
74 cat $filelist | rsync $rsyncopts ${mountdir%/}/ ${2%/}/
76 echo "No files are needed from disk: $date. Skipping it."