aboutsummaryrefslogtreecommitdiff
path: root/restore.in
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-05-17 16:24:48 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-05-17 16:24:48 +0300
commit459243cf5c5b8ac1d74355dee29ef1c1d5948e85 (patch)
tree162671794551beaf98366e6d378c42b5939987e8 /restore.in
parent6b8fa542771cc9a93a9ecdfb20da9cea0781f1c4 (diff)
downloadbeam-459243cf5c5b8ac1d74355dee29ef1c1d5948e85.tar.gz
beam-459243cf5c5b8ac1d74355dee29ef1c1d5948e85.tar.bz2
Bugfix.
* restore.in: Fix autodetection of last round and level numbers.
Diffstat (limited to 'restore.in')
-rw-r--r--restore.in74
1 files changed, 23 insertions, 51 deletions
diff --git a/restore.in b/restore.in
index c112cb6..ebcb3bc 100644
--- a/restore.in
+++ b/restore.in
@@ -16,34 +16,6 @@ dry_run=
listonly=
confirm=1
-guess_round() {
- case $1 in
- Sun|Mon|Tue)
- round=0;;
- Wed|Thu)
- round=1;;
- Fri|Sat)
- round=2;;
- *)
- echo >&2 "$0: invalid day of week ($1)"
- exit 1
- esac
-}
-
-guess_level() {
- case $1 in
- Sun)
- level=0;;
- Mon|Wed|Fri)
- level=1;;
- Tue|Thu|Sat)
- level=2;;
- *)
- echo >&2 "$0: invalid day of week ($1)"
- exit 1
- esac
-}
-
getyn() {
echo -n "$0:" $* " [Y/n]? "
read
@@ -112,33 +84,35 @@ if [ -n "$logfile" ]; then
exec 2>&1
fi
-# Verify option consistency, guess missing values
-hour=$(date +%H)
-if [ $hour -gt 6 ]; then
- thisweek=$(date +%U)
- yestreen=$(date +%a)
-else
- thisweek=$(date -d yesterday +%U)
- yestreen=$(date -d yesterday +%a)
-fi
+$prologue_hook
+test -z "$epilogue_hook" && trap "$epilogue_hook" EXIT INT QUIT TERM
+# Guess missing values
if [ -z "$week" ]; then
- week=$thisweek
+ hour=$(date +%H)
+ if [ $hour -gt 6 ]; then
+ week=$(date +%U)
+ else
+ week=$(date -d yesterday +%U)
+ fi
fi
+
if [ -z "$round" ]; then
- if [ $week = $thisweek ]; then
- guess_round $yestreen
- else
- round=2
- fi
+ round=$(find $backup_archive_dir \
+ -regex '.*-'$week'-[0-9][0-9]*-[0-9][0-9]*\..*' \
+ -printf '%f\n' |
+ sed 's/.*-'$week'-\([0-9][0-9]*\)-[0-9][0-9]*\..*/\1/' |
+ sort +0 -1 |
+ tail -1)
fi
+
if [ -z "$level" ]; then
- if [ $week = $thisweek ]; then
- guess_level $yestreen
- else
- # FIXME: A better guess?
- level=2
- fi
+ level=$(find $backup_archive_dir \
+ -regex '.*-'$week-$round'-[0-9][0-9]*\..*' \
+ -printf '%f\n' |
+ sed 's/.*-'$week-$round'-\([0-9][0-9]*\)\..*/\1/' |
+ sort +0 -1 |
+ tail -1)
fi
echo "$0: target root directory $root"
@@ -150,8 +124,6 @@ if [ $confirm -ne 0 ]; then
test $REPLY = "n" && exit 0
fi
-$prologue_hook
-
logit "started"
for item in $items

Return to:

Send suggestions and report system problems to the System administrator.