Added new remote server option. Added "force" behavior to take a disk not matching...
authorAlan Jack Pippin <ajp@pippin.(none)>
Wed, 22 Feb 2006 16:52:59 +0000 (09:52 -0700)
committerAlan J. Pippin <ajp@pippins.net>
Wed, 22 Feb 2006 16:52:59 +0000 (09:52 -0700)
scripts/restore-script.sh

index e4fba472fb79803735f4032fc5b131c631e02c01..af5a80cd684deee617c8cc4cedd522f6d6e3cca6 100755 (executable)
@@ -16,7 +16,7 @@ export PATH=${rundir%/}:/bin:/usr/bin:/sbin:/usr/sbin:/sw/bin
 if [ -z "$1" -o ! -d "$2" ]; then
   err "
 
-Usage: $(basename $0) <source-dir> <relocate-dir> [<mnt-dir>]
+Usage: $(basename $0) <source-dir> <relocate-dir> [<mnt-dir> [remote_user@remote_host]]
   source-dir   - Directory on backup disks to restore (relative to
                  $mountdir)
   relocate-dir - Base directory to restore files into (usually /)
@@ -53,6 +53,7 @@ for date in $dates; do
   cat $dbfile | files-from-date.sh $date | grep -z -Z -e "^${1%/}/" > $filelist
   if [ -s $filelist ]; then
     success=false
+    loop=0
     while ! $success; do
       eject $device
       [ $? != 0 ] && err "Cannot eject the disk. Drive is busy. Run lsof $mountdir to see why."
@@ -66,13 +67,23 @@ for date in $dates; do
 
       if grep -q $date ${mountdir%/}/backup-status.txt; then
         success=true
-      else
+      elif e2label $device | grep -q $date; then
+        success=true
+      elif [ $loop -gt 2 ]; then
+        echo "I still can't verify the identity of the disk."
+       echo "If you are sure it is correct, press Enter to continue."
+       echo "Otherwise, press CTRL-C to abort."
+       read bogus
+       success=true
+      else 
         echo "This doesn't seem to be the right disk."
+       loop=$((loop+1))
       fi
     done
 
     rsyncopts="-W -H -S -l -p -t -g -o -0 --files-from=- --stats --progress"
-    cat $filelist | rsync $rsyncopts ${mountdir%/}/ ${2%/}/
+    [ -z "$4" ] && cat $filelist | rsync $rsyncopts ${mountdir%/}/ ${2%/}/
+    [ -n "$4" ] && cat $filelist | rsync $rsyncopts -e ssh ${mountdir%/}/ ${4}:${2%/}/
   else
     echo "No files are needed from disk: $date.  Skipping it."
   fi