From: Alan Jack Pippin Date: Tue, 29 Nov 2005 07:35:56 +0000 (-0700) Subject: Added support for 3rd argument = mount dir X-Git-Tag: release-0.4~11 X-Git-Url: http://git.pippins.net/embedvideo/.git/%7Blink_hometeaching%7D?a=commitdiff_plain;h=9c5abcc59e83fa16bfeb810cc4d51960f8586a4e;p=backups%2F.git Added support for 3rd argument = mount dir Fixed bug related to automatically finding mountdir. Added usage verbosity. Added failure to eject the disk checking. --- diff --git a/scripts/restore-header.sh b/scripts/restore-header.sh index 8374076..b05d19c 100755 --- a/scripts/restore-header.sh +++ b/scripts/restore-header.sh @@ -8,7 +8,9 @@ if ! mkdir $rundir; then fi unset CDPATH -export mountdir=$(cd $(dirname $0) && pwd) +if [ -z "$3" ]; then + export mountdir=$(cd $(dirname $0) && pwd -P) +fi SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' $0` diff --git a/scripts/restore-script.sh b/scripts/restore-script.sh index 6592d72..66ac4fb 100755 --- a/scripts/restore-script.sh +++ b/scripts/restore-script.sh @@ -1,5 +1,14 @@ #!/bin/sh +function err() { + echo 2>&1 "-E- $1" + exit 1 +} + +if [ ! -z "$3" ]; then + mountdir=$3 +fi + if [ -z "$mountdir" ]; then echo >&2 '$mountdir must be set' exit 1 @@ -12,9 +21,12 @@ fi export PATH=${rundir%%/}:/bin:/usr/bin:/sbin:/usr/sbin:/sw/bin -if [ $# != 2 -o ! -d "$1" -o ! -d "$2" ]; then - echo >&2 "Usage: $0 " - echo >&2 "Example: $0 / /" +if [ ! -d "$1" -o ! -d "$2" ]; then + echo >&2 "Usage: $0 []" + echo >&2 " source-dir - directory on backup disks to restore from" + echo >&2 " target-dir - directory to restore files to" + echo >&2 " mnt-dir - directory where backup disk is mounted (optional)" + echo >&2 "Example: $0 / / /mnt/cdrom" exit 1 fi @@ -34,7 +46,9 @@ 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 >&2 "Please insert backup disk: $date" + echo >&2 "Press Enter to continue" read bogus eject -t $device @@ -44,10 +58,10 @@ for date in $dates; do if grep -q $date ${mountdir%%/}/backup-status.txt; then success=true else - echo >&2 "This doesn't seem to be the right disk." + 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 | rsync $rsyncopts ${mountdir%%/}/ ${2%%/}/ + cat $dbfile | files-from-date.sh $date | grep -z -e "${1}" | rsync $rsyncopts ${mountdir%%/}/ ${2%%/}/ done