forked from ungleich-public/ccollect
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:
parent
4b0298101a
commit
5ef6063fad
2 changed files with 47 additions and 28 deletions
66
ccollect.sh
66
ccollect.sh
|
@ -227,6 +227,15 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
begin=$($DDATE)
|
begin=$($DDATE)
|
||||||
begin_s=$(date +%s)
|
begin_s=$(date +%s)
|
||||||
|
|
||||||
|
#
|
||||||
|
# unset possible options
|
||||||
|
#
|
||||||
|
EXCLUDE=""
|
||||||
|
RSYNC_EXTRA=""
|
||||||
|
SUMMARY=""
|
||||||
|
VERBOSE=""
|
||||||
|
VVERBOSE=""
|
||||||
|
|
||||||
echo "$begin Beginning to backup"
|
echo "$begin Beginning to backup"
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -236,11 +245,30 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
echo "Source does not exist."
|
echo "Source does not exist."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# configuration _must_ be a directory
|
||||||
|
#
|
||||||
if [ ! -d "$backup" ]; then
|
if [ ! -d "$backup" ]; then
|
||||||
echo "\"$name\" is not a cconfig-directory. Skipping."
|
echo "\"$name\" is not a cconfig-directory. Skipping."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
# interval definition: First try source specific, fallback to default
|
||||||
#
|
#
|
||||||
|
@ -256,16 +284,7 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# unset possible options
|
# Source checks
|
||||||
#
|
|
||||||
EXCLUDE=""
|
|
||||||
RSYNC_EXTRA=""
|
|
||||||
SUMMARY=""
|
|
||||||
VERBOSE=""
|
|
||||||
VVERBOSE=""
|
|
||||||
|
|
||||||
#
|
|
||||||
# next configuration checks
|
|
||||||
#
|
#
|
||||||
if [ ! -f "$c_source" ]; then
|
if [ ! -f "$c_source" ]; then
|
||||||
echo "Source description $c_source is not a file. Skipping."
|
echo "Source description $c_source is not a file. Skipping."
|
||||||
|
@ -278,46 +297,45 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# destination _must_ be a directory
|
||||||
|
#
|
||||||
if [ ! -d "$c_dest" ]; then
|
if [ ! -d "$c_dest" ]; then
|
||||||
echo "Destination $c_dest does not link to a directory. Skipping"
|
echo "Destination $c_dest does not link to a directory. Skipping"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# pre_exec
|
# exclude list
|
||||||
#
|
#
|
||||||
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
|
|
||||||
if [ -f "$c_exclude" ]; then
|
if [ -f "$c_exclude" ]; then
|
||||||
EXCLUDE="--exclude-from=$c_exclude"
|
EXCLUDE="--exclude-from=$c_exclude"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
# extra options for rsync
|
# extra options for rsync
|
||||||
|
#
|
||||||
if [ -f "$c_rsync_extra" ]; then
|
if [ -f "$c_rsync_extra" ]; then
|
||||||
RSYNC_EXTRA="$(cat "$c_rsync_extra")"
|
RSYNC_EXTRA="$(cat "$c_rsync_extra")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
# Output a summary
|
# Output a summary
|
||||||
|
#
|
||||||
if [ -f "$c_summary" ]; then
|
if [ -f "$c_summary" ]; then
|
||||||
SUMMARY="--stats"
|
SUMMARY="--stats"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
# Verbosity for rsync
|
# Verbosity for rsync
|
||||||
|
#
|
||||||
if [ -f "$c_verbose" ]; then
|
if [ -f "$c_verbose" ]; then
|
||||||
VERBOSE="-v"
|
VERBOSE="-v"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
# MORE verbosity, includes standard verbosity
|
# MORE verbosity, includes standard verbosity
|
||||||
|
#
|
||||||
if [ -f "$c_vverbose" ]; then
|
if [ -f "$c_vverbose" ]; then
|
||||||
VERBOSE="-v"
|
VERBOSE="-v"
|
||||||
VVERBOSE="-v"
|
VVERBOSE="-v"
|
||||||
|
@ -327,7 +345,7 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
# check if maximum number of backups is reached, if so remove
|
# 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')
|
count=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | wc -l | sed 's/^ *//g')
|
||||||
echo -n "Currently $count backup(s) exist(s),"
|
echo -n "Currently $count backup(s) exist(s),"
|
||||||
echo " total keeping $c_interval backup(s)."
|
echo " total keeping $c_interval backup(s)."
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
0.4 to 0.4.1:
|
0.4 to 0.4.1:
|
||||||
* updated documentation
|
* updated documentation
|
||||||
* created new document formats: Texinfo and manpage
|
* created new document formats: Texinfo and manpage
|
||||||
|
* fixed problem with 'make install' (strip was used)
|
||||||
|
|
||||||
0.3.3 to 0.4:
|
0.3.3 to 0.4:
|
||||||
* `pax` (Posix) is now required, `cp -al` (GNU specific) is removed
|
* `pax` (Posix) is now required, `cp -al` (GNU specific) is removed
|
||||||
|
|
Loading…
Reference in a new issue