aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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.