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
41 # Check to see if files are actually needed from the current disk before requesting it.
42 cat $dbfile | files-from-date.sh $date | grep -z -Z -e "^${1%/}/" > $filelist
43 if [ -s $filelist ]; then
47 [ $? != 0 ] && err "Cannot eject the disk. Drive is busy. Run lsof $mountdir to see why."
48 echo "Please insert backup disk: $date"
49 echo "Press Enter to continue"
54 mount -t ext2 $device ${mountdir%/}
56 if grep -q $date ${mountdir%/}/backup-status.txt; then
59 echo "This doesn't seem to be the right disk."
63 rsyncopts="-W -H -S -l -p -t -g -o -0 --files-from=- --stats --progress"
64 cat $filelist | rsync $rsyncopts ${mountdir%/}/ ${2%/}/
66 echo "No files are needed from disk: $date. Skipping it."