12 if [ -z "$mountdir" ]; then
13 echo >&2 '$mountdir must be set'
17 if [ -z "$rundir" ]; then
18 echo >&2 '$rundir must be set'
22 export PATH=${rundir%%/}:/bin:/usr/bin:/sbin:/usr/sbin:/sw/bin
24 if [ ! -d "$1" -o ! -d "$2" ]; then
25 echo >&2 "Usage: $0 <source-dir> <target-dir> [<mnt-dir>]"
26 echo >&2 " source-dir - directory on backup disks to restore from"
27 echo >&2 " target-dir - directory to restore files to"
28 echo >&2 " mnt-dir - directory where backup disk is mounted (optional)"
29 echo >&2 "Example: $0 / / /mnt/cdrom"
33 device=$(mount | grep "on ${mountdir%%/} " | awk '{print$1}')
35 if [ -z "$device" ]; then
36 echo >&2 "Cannot determine cdrom device"
40 cp ${mountdir%%/}/backups.db ${mountdir%%/}/backup-status.txt $rundir
41 dbfile=${rundir%%/}/backups.db
43 dates=$(cat $dbfile | list-dates.sh)
45 for date in $dates; do
49 [ $? != 0 ] && err "Cannot eject the disk. Drive is busy. Run lsof $mountdir to see why."
50 echo >&2 "Please insert backup disk: $date"
51 echo >&2 "Press Enter to continue"
56 mount -t ext2 $device ${mountdir%%/}
58 if grep -q $date ${mountdir%%/}/backup-status.txt; then
61 echo "This doesn't seem to be the right disk."
65 rsyncopts="-W -H -S -l -p -t -g -o -0 --files-from=- --stats --progress"
66 cat $dbfile | files-from-date.sh $date | grep -z -e "${1}" | rsync $rsyncopts ${mountdir%%/}/ ${2%%/}/