X-Git-Url: http://git.pippins.net/embedvideo/.git/static/git-logo.png?a=blobdiff_plain;f=scripts%2Frestore-script.sh;h=42fe9000e60ccb06d15fecd529eb5ad336fdc29f;hb=7c962b0ad5636ad286132aaeda3badac76ceeace;hp=402bb840cb7084966f1ad7522420d5d2d3547e7e;hpb=cb9371796a05c3ab8e74310e78a8d75e980a7b19;p=backups%2F.git diff --git a/scripts/restore-script.sh b/scripts/restore-script.sh old mode 100644 new mode 100755 index 402bb84..42fe900 --- a/scripts/restore-script.sh +++ b/scripts/restore-script.sh @@ -1,24 +1,35 @@ #!/bin/sh +export PATH=$rundir:/bin:/usr/bin + if [ $# != 1 ]; then - echo >&2 "Usage: $0 " - echo >&2 "Example: $0 /" + echo >&2 "Usage: $0 " + echo >&2 "Example: $0 / /" exit 1 fi -tmpdir=/tmp/restore-$(date +%Y%m%d%H%M%S) - -export PATH=$tmpdir:/bin:/usr/bin +device=$(mount | grep "on $mountdir " | awk '{print$1}') -# Get the device with the CD in it here -device=/dev/hdc +cp $mountdir/backups.db $mountdir/backup-status.txt $rundir +dbfile=$rundir/backups.db for date in $(cat $dbfile | list-dates.sh); do - eject $device - echo >&2 "Please insert backup disk: $date" - echo >&2 "Then press any key" - read bogus - # Mount the media - # rsync-cmd.sh won't work here in its current encarnation - cat $dbfile | files-from-date.sh | rsync-cmd.sh $1 + success=false + while ! $success; do + eject $device + echo >&2 "Please insert backup disk: $date" + read bogus + eject -t $device + + # Mount the media + mount -t ext2 $device $mountdir + if [ "" != "$(grep -l $date $mountdir/backup-status.txt)" ]; then + success=true + else + echo >&2 "This doesn't seem to be the right disk." + fi + done + + rsyncopts="-l -p -t -g -o -0 --files-from=- --stats --progress " + cat $dbfile | files-from-date.sh | rsync $rsyncopts $mountdir $2 done