Pre_exec problem, resorting

Pre_exec has to be executed first, because it may create other
configuration options (including mounting the destination!)
(the problem was reported by Tonnerre Lombard).

Also added more beautiful comments.
This commit is contained in:
Nico Schottelius 2006-06-13 12:04:36 +02:00
parent 4b0298101a
commit 5ef6063fad
2 changed files with 47 additions and 28 deletions

View File

@ -227,6 +227,15 @@ while [ "$i" -lt "$no_sources" ]; do
begin=$($DDATE)
begin_s=$(date +%s)
#
# unset possible options
#
EXCLUDE=""
RSYNC_EXTRA=""
SUMMARY=""
VERBOSE=""
VVERBOSE=""
echo "$begin Beginning to backup"
#
@ -236,11 +245,30 @@ while [ "$i" -lt "$no_sources" ]; do
echo "Source does not exist."
exit 1
fi
#
# configuration _must_ be a directory
#
if [ ! -d "$backup" ]; then
echo "\"$name\" is not a cconfig-directory. Skipping."
exit 1
fi
#
# first execute pre_exec, which may generate destination or other
# parameters
#
if [ -x "$c_pre_exec" ]; then
echo "Executing $c_pre_exec ..."
"$c_pre_exec"
echo "Finished ${c_pre_exec}."
if [ $? -ne 0 ]; then
echo "$c_pre_exec failed, aborting backup."
exit 1
fi
fi
#
# interval definition: First try source specific, fallback to default
#
@ -256,16 +284,7 @@ while [ "$i" -lt "$no_sources" ]; do
fi
#
# unset possible options
#
EXCLUDE=""
RSYNC_EXTRA=""
SUMMARY=""
VERBOSE=""
VVERBOSE=""
#
# next configuration checks
# Source checks
#
if [ ! -f "$c_source" ]; then
echo "Source description $c_source is not a file. Skipping."
@ -278,46 +297,45 @@ while [ "$i" -lt "$no_sources" ]; do
fi
fi
#
# destination _must_ be a directory
#
if [ ! -d "$c_dest" ]; then
echo "Destination $c_dest does not link to a directory. Skipping"
exit 1
fi
#
# pre_exec
#
if [ -x "$c_pre_exec" ]; then
echo "Executing $c_pre_exec ..."
"$c_pre_exec"
echo "Finished ${c_pre_exec}."
if [ $? -ne 0 ]; then
echo "$c_pre_exec failed, aborting backup."
exit 1
fi
fi
# exclude
#
# exclude list
#
if [ -f "$c_exclude" ]; then
EXCLUDE="--exclude-from=$c_exclude"
fi
#
# extra options for rsync
#
if [ -f "$c_rsync_extra" ]; then
RSYNC_EXTRA="$(cat "$c_rsync_extra")"
fi
#
# Output a summary
#
if [ -f "$c_summary" ]; then
SUMMARY="--stats"
fi
#
# Verbosity for rsync
#
if [ -f "$c_verbose" ]; then
VERBOSE="-v"
fi
#
# MORE verbosity, includes standard verbosity
#
if [ -f "$c_vverbose" ]; then
VERBOSE="-v"
VVERBOSE="-v"
@ -327,7 +345,7 @@ while [ "$i" -lt "$no_sources" ]; do
# check if maximum number of backups is reached, if so remove
#
# the created directories are named $INTERVAL.$DA
# the created directories are named $INTERVAL-$DATE-$TIME.$PID
count=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | wc -l | sed 's/^ *//g')
echo -n "Currently $count backup(s) exist(s),"
echo " total keeping $c_interval backup(s)."

View File

@ -1,6 +1,7 @@
0.4 to 0.4.1:
* updated documentation
* created new document formats: Texinfo and manpage
* fixed problem with 'make install' (strip was used)
0.3.3 to 0.4:
* `pax` (Posix) is now required, `cp -al` (GNU specific) is removed