aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robin Obůrka <r.oburka@gmail.com> 2016-07-24 16:38:38 +0200
committerGravatar Robin Obůrka <r.oburka@gmail.com> 2016-07-24 16:38:38 +0200
commit50eeb0cf0e67d14824dfc666e0f8885b33aaf78c (patch)
treed351ff2d89b975d84702967632235a41674d2356
parentReport what failed (diff)
downloadbackuper-50eeb0cf0e67d14824dfc666e0f8885b33aaf78c.tar.xz
Report time of every stage
-rw-r--r--backuper.sh18
1 files changed, 10 insertions, 8 deletions
diff --git a/backuper.sh b/backuper.sh
index eac86aa..a19bbd8 100644
--- a/backuper.sh
+++ b/backuper.sh
@@ -3,9 +3,6 @@
## Settings
GPG_RECIPIENT="robin.oburka@nic.cz"
-## Style
-TIME_FMT="\nBackup took:\t%E"
-
## Internal variables - backup process
NAME=""
REMOTE=""
@@ -36,6 +33,12 @@ get_size() {
du -h "$FILE" | awk '{ print $1 }'
}
+time_fmt() {
+ TXT="$1"
+ TIME_FMT="\n$TXT:\t%E"
+ echo "$TIME_FMT"
+}
+
## Getting data helpers
get_home() {
CURRENT_USER="$(id --real --user --name)"
@@ -108,8 +111,7 @@ after() {
run() {
title "Run command"
echo "$@"
- echo $@ | $REMOTE sh -s
- printf "\n"
+ echo $@ | /usr/bin/time -f "$(time_fmt "Command took")" $REMOTE sh -s
}
store_file() {
@@ -168,7 +170,7 @@ cleanup() {
backup_done() {
if [ -n "$AFTER" ]; then
title "After backup hook"
- echo "$AFTER" | sh -s || die "After-backup hook failed"
+ echo "$AFTER" | /usr/bin/time -f "$(time_fmt "Command took")" sh -s || die "After-backup hook failed"
fi
}
@@ -199,10 +201,10 @@ start_store() {
start_command() {
title "Create backup"
if [ -n "$COMMAND" ]; then
- echo "$COMMAND" | /usr/bin/time -f "$TIME_FMT" $REMOTE $GENERATE sh -s > "$RUNDIR"/fifo_0
+ echo "$COMMAND" | /usr/bin/time -f "$(time_fmt "Backup took")" $REMOTE $GENERATE sh -s > "$RUNDIR"/fifo_0
else
## Exclude keep without quotes
- /usr/bin/time -f "$TIME_FMT" $REMOTE $GENERATE tar c --preserve-permissions $EXCLUDE "$PLACES" > "$RUNDIR"/fifo_0
+ /usr/bin/time -f "$(time_fmt "Backup took")" $REMOTE $GENERATE tar c --preserve-permissions $EXCLUDE "$PLACES" > "$RUNDIR"/fifo_0
fi
}