From: Carl N. Baldwin Date: Wed, 26 Oct 2005 02:59:59 +0000 (-0600) Subject: Clean up X-Git-Tag: release-0.4~60 X-Git-Url: http://git.pippins.net/embedvideo/.git/images/x.gif?a=commitdiff_plain;h=ec0fa7c570c25174b2749ec2314746cb1d513ab8;p=backups%2F.git Clean up --- diff --git a/scripts/files-from-date.sh b/scripts/files-from-date.sh index 80c0ad3..2db6fc2 100755 --- a/scripts/files-from-date.sh +++ b/scripts/files-from-date.sh @@ -2,4 +2,4 @@ [ $# == 1 ] || exit 1 -awk --posix 'BEGIN { RS="\0" } { d=$7; gsub( /^([^ ]*[ ]){7,7}/, "" ); if ( date == d ) printf "%s\0",$0 }' date=$1 +gawk --posix 'BEGIN { RS="\0" } { d=$7; gsub( /^([^ ]*[ ]){7,7}/, "" ); if ( date == d ) printf "%s\0",$0 }' date=$1 diff --git a/scripts/list-dates.sh b/scripts/list-dates.sh index 1e6b501..ba28d5b 100755 --- a/scripts/list-dates.sh +++ b/scripts/list-dates.sh @@ -1,3 +1,3 @@ #!/bin/sh -awk 'BEGIN { RS="\0" } {print$7}' | sort -u +gawk 'BEGIN { RS="\0" } {print$7}' | sort -u diff --git a/scripts/restore-script.sh b/scripts/restore-script.sh index 42fe900..acd9008 100755 --- a/scripts/restore-script.sh +++ b/scripts/restore-script.sh @@ -1,19 +1,36 @@ #!/bin/sh -export PATH=$rundir:/bin:/usr/bin +if [ -z "$mountdir" ]; then + echo >&2 '$mountdir must be set' + exit 1 +fi + +if [ -z "$rundir" ]; then + echo >&2 '$rundir must be set' + exit 1 +fi + +export PATH=${rundir%%/}:/bin:/usr/bin:/sbin:/usr/sbin:/sw/bin -if [ $# != 1 ]; then +if [ $# != 2 -o ! -d "$1" -o ! -d "$2" ]; then echo >&2 "Usage: $0 " echo >&2 "Example: $0 / /" exit 1 fi -device=$(mount | grep "on $mountdir " | awk '{print$1}') +device=$(mount | grep "on ${mountdir%%/} " | awk '{print$1}') -cp $mountdir/backups.db $mountdir/backup-status.txt $rundir -dbfile=$rundir/backups.db +if [ -z "$device" ]; then + echo >&2 "Cannot determine cdrom device" + exit 1 +fi + +cp ${mountdir%%/}/backups.db ${mountdir%%/}/backup-status.txt $rundir +dbfile=${rundir%%/}/backups.db -for date in $(cat $dbfile | list-dates.sh); do +dates=$(cat $dbfile | list-dates.sh) + +for date in $dates; do success=false while ! $success; do eject $device @@ -22,14 +39,15 @@ for date in $(cat $dbfile | list-dates.sh); do eject -t $device # Mount the media - mount -t ext2 $device $mountdir - if [ "" != "$(grep -l $date $mountdir/backup-status.txt)" ]; then + mount -t ext2 $device ${mountdir%%/} + + if grep -q $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 + rsyncopts="-l -p -t -g -o -0 --files-from=- --stats --progress" + cat $dbfile | files-from-date.sh $date | rsync $rsyncopts ${mountdir%%/}/ ${2%%/}/ done