[ -z "$mountdir" ] && err '$mountdir must be set'
[ -z "$rundir" ] && err '$rundir must be set'
-export PATH=${rundir%%/}:/bin:/usr/bin:/sbin:/usr/sbin:/sw/bin
+export PATH=${rundir%/}:/bin:/usr/bin:/sbin:/usr/sbin:/sw/bin
if [ ! -z "$1" -o ! -d "$2" ]; then
err "
"
fi
-device=$(mount | grep "on ${mountdir%%/} " | awk '{print$1}')
+device=$(mount | grep "on ${mountdir%/} " | awk '{print$1}')
[ -z "$device" ] && err "Cannot determine cdrom device"
-cp ${mountdir%%/}/backups.db ${mountdir%%/}/backup-status.txt $rundir
-dbfile=${rundir%%/}/backups.db
+cp ${mountdir%/}/backups.db ${mountdir%/}/backup-status.txt $rundir
+dbfile=${rundir%/}/backups.db
dates=$(cat $dbfile | list-dates.sh)
for date in $dates; do
filelist=$(tempfile)
# Check to see if files are actually needed from the current disk before requesting it.
- cat $dbfile | files-from-date.sh $date | grep -z -Z -e "^${1%%/}/" > $filelist
+ cat $dbfile | files-from-date.sh $date | grep -z -Z -e "^${1%/}/" > $filelist
if [ -s $filelist ]; then
success=false
while ! $success; do
eject -t $device
# Mount the media
- mount -t ext2 $device ${mountdir%%/}
+ mount -t ext2 $device ${mountdir%/}
- if grep -q $date ${mountdir%%/}/backup-status.txt; then
+ if grep -q $date ${mountdir%/}/backup-status.txt; then
success=true
else
echo "This doesn't seem to be the right disk."
done
rsyncopts="-W -H -S -l -p -t -g -o -0 --files-from=- --stats --progress"
- cat $filelist | rsync $rsyncopts ${mountdir%%/}/ ${2%%/}/
+ cat $filelist | rsync $rsyncopts ${mountdir%/}/ ${2%/}/
else
echo "No files are needed from disk: $date. Skipping it."
fi