}
ErrorMsg () {
- printf "%s\n" "$@" >&2
+ printf "%s\\n" "$@" >&2
}
CleanUp() {
ErrorMsg "--> Got signal, cleaning up & aborting ..."
echo
CleanUp
- ErrorMsg -n "Aborted: " >&2; date
+ ErrorMsg "Aborted: $(date)" >&2
echo
sleep 3
exit 9
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=$?
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
esac
done
-echo -n "Started: "; date
+echo "Started: $(date)"
echo -e "$config_info"
# Check rsync and its protocol version
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
&& cmd="$cmd ${user}@${system}:$source_root $sys_target/" \
|| cmd="$cmd $source_root $sys_target/"
elif [[ "$backup_type" == "scp" ]]; then
- cmd="scp"
+ # scp writes some warning messages to stderr (like "Connection
+ # to ... closed by remote host."), even when there is no error
+ # and the exit code is 0 ("no error"); therefore we redirect
+ # stderr to stdout to not confuse "mail wrapper scripts" etc.
+ cmd="scp 2>&1"
[ "$VERBOSE" -eq 0 ] && cmd="$cmd -q"
for file in $files; do
cmd="$cmd ${user}@${system}:$file $sys_target/"
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
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
|| 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
CleanUp
-echo -n "Done: "; date
+echo "Done: $(date)"
echo
[ $count_all -eq 1 ] && s="" || s="s"
[ $count_enabled -eq $count_all ] \