X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=bin%2Fbackup-script;h=89b066db8bddddcabff66b15c30df1ebfd161e62;hb=d1df3a8e7472d91b1356fcb20862bc738f3d0215;hp=84180d3e5e0d1c366b2cb7135e2aa13a755a549b;hpb=dc62385b6c1db1f36f3b58fa9a44ffed31d5cb3e;p=backup-script.git diff --git a/bin/backup-script b/bin/backup-script index 84180d3..89b066d 100755 --- a/bin/backup-script +++ b/bin/backup-script @@ -53,6 +53,9 @@ default_job_pre_exec="" default_job_post_exec="" default_tags="" +# Set shell options. +shopt -s nullglob + Usage() { { echo "Usage: $NAME [] [ [ [...]]]" @@ -72,7 +75,7 @@ Usage() { } ErrorMsg () { - printf "%s\n" "$@" >&2 + printf "%s\\n" "$@" >&2 } CleanUp() { @@ -91,7 +94,7 @@ GotSignal() { ErrorMsg "--> Got signal, cleaning up & aborting ..." echo CleanUp - ErrorMsg -n "Aborted: " >&2; date + ErrorMsg "Aborted: $(date)" >&2 echo sleep 3 exit 9 @@ -104,7 +107,7 @@ ExecJob() { echo "Running job ${what}-exec command ..." [ "$local" -eq 0 ] \ && cmd="$ssh_cmd ${user}@${system} $cmd" - echo -n "Start date (${what}-exec): "; date + echo "Start date (${what}-exec): $(date)" echo "$cmd" if [ "$DRYRUN" -eq 0 ]; then $SHELL -c "$cmd"; local ret=$? @@ -300,7 +303,7 @@ if [ -r "$conf" ]; then else config_info="${config_info} (not readable, using defaults)" fi -config_info="${config_info},\nusing \"$conf_d\" as configuration directory." +config_info="${config_info},\\nusing \"$conf_d\" as configuration directory." while [ $# -gt 0 ]; do case "$1" in @@ -325,7 +328,7 @@ while [ $# -gt 0 ]; do esac done -echo -n "Started: "; date +echo "Started: $(date)" echo -e "$config_info" # Check rsync and its protocol version @@ -372,7 +375,7 @@ if [ -e "$PIDFILE" ]; then ErrorMsg "Lockfile \"$PIDFILE\" already exists." ErrorMsg "Is an other instance still running?" echo - ErrorMsg -n "Aborted: " >&2; date + ErrorMsg "Aborted: $(date)" >&2 echo exit 4 fi @@ -654,7 +657,7 @@ for f in "${sys[@]}"; do fi echo "Backing up to \"$sys_target\" ..." - echo -n "Start date: "; date + echo "Start date: $(date)" echo "$cmd" count_started=$count_started+1 ok=0 @@ -686,7 +689,7 @@ for f in "${sys[@]}"; do GotSignal fi - echo -n "End date: "; date + echo "End date: $(date)" if [[ $ret -eq 0 || $ret -eq 24 ]]; then [ $ret -eq 24 ] && count_ok_vanished=$count_ok_vanished+1 @@ -731,7 +734,7 @@ for f in "${sys[@]}"; do || ErrorMsg "Failed to delete \"$dir\" of \"$system\"!" fi done - echo -n "Clean up finished: "; date + echo "Clean up finished: $(date)" elif [ -n "$to_delete" ]; then ErrorMsg "There have been errors for \"$system\", not cleaning up old generations!" else @@ -773,7 +776,7 @@ fi CleanUp -echo -n "Done: "; date +echo "Done: $(date)" echo [ $count_all -eq 1 ] && s="" || s="s" [ $count_enabled -eq $count_all ] \