Added partial parallel execution, added new error and standard message

printing
This commit is contained in:
Nico Schottelius 2006-01-09 13:24:27 +01:00
parent 99dac80acd
commit 6d925823bc
1 changed files with 23 additions and 7 deletions

View File

@ -13,6 +13,11 @@ CDEFAULTS=$CCOLLECT_CONF/defaults
TMP=$(mktemp /tmp/$(basename $0).XXXXXX) TMP=$(mktemp /tmp/$(basename $0).XXXXXX)
WE=$(basename $0) WE=$(basename $0)
#
# unset parallel execution
#
PARALLEL=""
# #
# catch signals # catch signals
# #
@ -20,13 +25,17 @@ trap "rm -f \"$TMP\"" 1 2 15
# #
# errors! # output and errors
# #
errecho() errecho()
{ {
echo "|E> Error: $@" >&2 echo "[$name][err] $@" >&2
} }
stdecho()
{
echo "[$name] $@"
}
# #
# Tell how to use us # Tell how to use us
@ -88,7 +97,7 @@ while [ $i -le $# ]; do
VERBOSE=1 VERBOSE=1
;; ;;
-p|--parallel) -p|--parallel)
PARALLEL=1 PARALLEL="&"
;; ;;
-h|--help) -h|--help)
usage usage
@ -164,8 +173,9 @@ while [ "$i" -lt "$no_shares" ]; do
c_dest="$backup/destination" c_dest="$backup/destination"
c_exclude="$backup/exclude" c_exclude="$backup/exclude"
c_verbose="$backup/verbose" c_verbose="$backup/verbose"
c_rsync_extra="$backup/rsync_options"
echo "/=> Beginning to backup \"$name\" ..." echo "Beginning to backup \"$name\" ..."
i=$[$i+1] i=$[$i+1]
# #
@ -181,7 +191,7 @@ while [ "$i" -lt "$no_shares" ]; do
fi fi
# #
# intervall definiition: First try source specific, fallback to default # intervall definition: First try source specific, fallback to default
# #
c_intervall="$(cat "$backup/intervalls/$INTERVALL" 2>/dev/null)" c_intervall="$(cat "$backup/intervalls/$INTERVALL" 2>/dev/null)"
@ -199,6 +209,7 @@ while [ "$i" -lt "$no_shares" ]; do
# #
VERBOSE="" VERBOSE=""
EXCLUDE="" EXCLUDE=""
RSYNC_EXTRA=""
# #
# next configuration checks # next configuration checks
@ -224,6 +235,11 @@ while [ "$i" -lt "$no_shares" ]; do
EXCLUDE="--exclude-from=$c_exclude" EXCLUDE="--exclude-from=$c_exclude"
fi fi
# extra options for rsync
if [ -f "$c_rsync_extra" ]; then
RSYNC_EXTRA="$(cat "$c_rsync_extra")"
fi
# verbose # verbose
if [ -f "$c_verbose" ]; then if [ -f "$c_verbose" ]; then
VERBOSE="-v" VERBOSE="-v"
@ -264,7 +280,7 @@ while [ "$i" -lt "$no_shares" ]; do
# only copy if a directory exists # only copy if a directory exists
if [ "$last_dir" ]; then if [ "$last_dir" ]; then
cp $VERBOSE -al "$last_dir" "$destination_dir" cp "$VERBOSE" -al "$last_dir" "$destination_dir"
else else
mkdir "$destination_dir" mkdir "$destination_dir"
fi fi
@ -280,7 +296,7 @@ while [ "$i" -lt "$no_shares" ]; do
# #
rsync -a "$VERBOSE" --delete --numeric-ids --relative --delete-excluded \ rsync -a "$VERBOSE" --delete --numeric-ids --relative --delete-excluded \
"$EXCLUDE" "$source" "$destination_dir" "$EXCLUDE" "$RSYNC_EXTRA" "$source" "$destination_dir"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
errecho "rsync failed, backup may be broken (see rsync errors)" errecho "rsync failed, backup may be broken (see rsync errors)"