X-Git-Url: http://git.pippins.net/embedvideo/.git/static/gitweb.js?a=blobdiff_plain;f=scripts%2Frestore-script.sh;h=daff5e571c414660f82e3e6d4da1c0e9de91cabd;hb=630a0aa5bb68026faa94652f9165ba593b084771;hp=9d9baabc9389a496e5a0db8771844331befe7f6b;hpb=2b19c613bbb418da0fff6cddaa01a21b87271cb1;p=backups%2F.git diff --git a/scripts/restore-script.sh b/scripts/restore-script.sh index 9d9baab..daff5e5 100755 --- a/scripts/restore-script.sh +++ b/scripts/restore-script.sh @@ -12,7 +12,7 @@ function err() { export PATH=${rundir%%/}:/bin:/usr/bin:/sbin:/usr/sbin:/sw/bin -if [ ! -d "$mountdir$1" -o ! -d "$2" ]; then +if [ ! -z "$1" -o ! -d "$2" ]; then err " Usage: $0 [] source-dir - directory on backup disks to restore from (relative to $mountdir) @@ -37,25 +37,33 @@ dbfile=${rundir%%/}/backups.db dates=$(cat $dbfile | list-dates.sh) for date in $dates; do - success=false - while ! $success; do - eject $device - [ $? != 0 ] && err "Cannot eject the disk. Drive is busy. Run lsof $mountdir to see why." - echo "Please insert backup disk: $date" - echo "Press Enter to continue" - read bogus - eject -t $device - - # Mount the media - mount -t ext2 $device ${mountdir%%/} - - if grep -q $date ${mountdir%%/}/backup-status.txt; then - success=true - else - echo "This doesn't seem to be the right disk." - fi - done - - rsyncopts="-W -H -S -l -p -t -g -o -0 --files-from=- --stats --progress" - cat $dbfile | files-from-date.sh $date | grep -z -Z -e "^${1}" | rsync $rsyncopts ${mountdir%%/}/ ${2%%/}/ + 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 + if [ -s $filelist ]; then + success=false + while ! $success; do + eject $device + [ $? != 0 ] && err "Cannot eject the disk. Drive is busy. Run lsof $mountdir to see why." + echo "Please insert backup disk: $date" + echo "Press Enter to continue" + read bogus + eject -t $device + + # Mount the media + mount -t ext2 $device ${mountdir%%/} + + if grep -q $date ${mountdir%%/}/backup-status.txt; then + success=true + else + echo "This doesn't seem to be the right disk." + fi + done + + rsyncopts="-W -H -S -l -p -t -g -o -0 --files-from=- --stats --progress" + cat $filelist | rsync $rsyncopts ${mountdir%%/}/ ${2%%/}/ + else + echo "No files are needed from disk: $date. Skipping it." + fi + rm -f $filelist done