Reorder: All checks being done in the same place

All configurations are checked in the same place

Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
This commit is contained in:
Nico Schottelius 2009-07-27 09:37:50 +02:00
parent cbf1b7cf0e
commit 483cfee90c

View file

@ -278,13 +278,14 @@ while [ "${i}" -lt "${no_sources}" ]; do
fi
#
# Read Configuration
# Read / create configuration
#
backup="${CSOURCES}/${name}"
c_source="${backup}/source"
c_dest="${backup}/destination"
c_pre_exec="${backup}/pre_exec"
c_post_exec="${backup}/post_exec"
c_marker=".ccollect-marker"
for opt in exclude verbose very_verbose rsync_options summary delete_incomplete \
remote_host rsync_failure_codes mtime quiet_if_down ; do
if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then
@ -301,11 +302,6 @@ while [ "${i}" -lt "${no_sources}" ]; do
TSORT="t"
fi
#
# Marking backups: If we abort it's not removed => Backup is broken
#
c_marker=".ccollect-marker"
#
# First execute pre_exec, which may generate destination or other parameters
#
@ -320,7 +316,7 @@ while [ "${i}" -lt "${no_sources}" ]; do
fi
#
# Source checks
# Source configuration checks
#
if [ ! -f "${c_source}" ]; then
_exit_err "Source description \"${c_source}\" is not a file. Skipping."
@ -331,16 +327,6 @@ while [ "${i}" -lt "${no_sources}" ]; do
fi
fi
#
# Verify source is up and accepting connections before deleting any old backups
#
if ! rsync "${source}" >/dev/null 2>"${TMP}" ; then
if [ ! -f "${c_quiet_if_down}" ]; then
cat "${TMP}"
fi
_exit_err "Source ${source} is not readable. Skipping."
fi
#
# Destination is a path
#
@ -368,23 +354,18 @@ while [ "${i}" -lt "${no_sources}" ]; do
fi
export remote_host
#
# check for existence / use real name
#
( pcmd cd "$ddir" ) || _exit_err "Cannot change to ${ddir}. Skipping."
#
# Parameters: ccollect defaults, configuration options, user options
#
#
# rsync standard options
# Rsync standard options
#
set -- "$@" "--archive" "--delete" "--numeric-ids" "--relative" \
"--delete-excluded" "--sparse"
#
# exclude list
# Exclude list
#
if [ -f "${c_exclude}" ]; then
set -- "$@" "--exclude-from=${c_exclude}"
@ -409,7 +390,7 @@ while [ "${i}" -lt "${no_sources}" ]; do
fi
#
# extra options for rsync provided by the user
# Extra options for rsync provided by the user
#
if [ -f "${c_rsync_options}" ]; then
while read line; do
@ -418,7 +399,22 @@ while [ "${i}" -lt "${no_sources}" ]; do
fi
#
# Check for incomplete backups
# Check: source is up and accepting connections (before deleting old backups!)
#
if ! rsync "${source}" >/dev/null 2>"${TMP}" ; then
if [ ! -f "${c_quiet_if_down}" ]; then
cat "${TMP}"
fi
_exit_err "Source ${source} is not readable. Skipping."
fi
#
# Check: destination exists?
#
( pcmd cd "${ddir}" ) || _exit_err "Cannot change to ${ddir}. Skipping."
#
# Check: incomplete backups?
#
pcmd ls -1 "${ddir}/"*".${c_marker}" 2>/dev/null | while read marker; do
incomplete="$(echo ${marker} | sed "s/\\.${c_marker}\$//")"