diff options
Diffstat (limited to 'backuper.sh')
-rw-r--r-- | backuper.sh | 18 |
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 } |