projects
/
backups
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some fixes to burn script
[backups/.git]
/
scripts
/
restore-script.sh
diff --git
a/scripts/restore-script.sh
b/scripts/restore-script.sh
index 1bf8dccfd4e8326670ef9ef189598d24c6cecc33..acd90081c17aa632ec6d17c1de9290491935e1d6 100755
(executable)
--- a/
scripts/restore-script.sh
+++ b/
scripts/restore-script.sh
@@
-1,34
+1,53
@@
#!/bin/sh
#!/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 <source-directory> <target-directory>"
echo >&2 "Example: $0 / /"
exit 1
fi
echo >&2 "Usage: $0 <source-directory> <target-directory>"
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
echo >&2 "Please insert backup disk: $date"
read bogus
success=false
while ! $success; do
eject $device
echo >&2 "Please insert backup disk: $date"
read bogus
+ eject -t $device
# Mount the media
# 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
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 $1 $2
+ rsyncopts="-l -p -t -g -o -0 --files-from=- --stats --progress"
+ cat $dbfile | files-from-date.sh
$date | rsync $rsyncopts ${mountdir%%/}/ ${2%%/}/
done
done