#!/bin/bash
#
# backup-script system for cloning systems using rsync
-# Copyright (c)2008-2015 Alexander Barton <alex@barton.de>
+# Copyright (c)2008-2016 Alexander Barton <alex@barton.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
&& cmd="$cmd --info=progress2" \
|| cmd="$cmd --progress"
fi
+ set -f
if [ "$source_root" = "$default_source_root" ]; then
for dir in \
"/dev/**" \
cmd="$cmd --exclude=$dir"
done
[ -n "$rsync_args_add" ] && cmd="$cmd $rsync_args_add"
+ set +f
[ "$local" -eq 0 ] \
&& cmd="$cmd ${user}@${system}:$source_root $sys_target/" \
ok=0
if [ "$DRYRUN" -eq 0 ]; then
- rm -f "$sys_target/.stamp"
+ stamp_file="$sys_target/.stamp"
+ rm -f "$stamp_file"
+
+ # Execute backup command:
+ start_t=$(date "+%s")
$SHELL -c "$cmd"; ret=$?
- echo "code=$ret" >"$sys_target/.stamp"
+ end_t=$(date "+%s")
+
+ echo "code=$ret" >"$stamp_file"
+ echo "start_t=$start_t" >>"$stamp_file"
+ echo "end_t=$end_t" >>"$stamp_file"
+ echo "cmd='$cmd'" >>"$stamp_file"
+ echo "backup_host='`hostname -f`'" >>"$stamp_file"
+ echo "backup_user='`id -un`'" >>"$stamp_file"
else
echo " *** Trial run, not executing save command!"
ret=0
elif [ -n "$to_delete" ]; then
echo "There have been errors, not cleaning up old generations!"
else
- echo "Nothing to clean up."
+ echo "Nothing to clean up (keep up to $generations generations)."
fi
fi