Cosmetic changes (II) plus integration of _exit_err
This commit is contained in:
parent
26d61c8c2c
commit
c291d4a8f5
1 changed files with 35 additions and 42 deletions
77
ccollect.sh
77
ccollect.sh
|
@ -14,8 +14,8 @@ CPREEXEC="$CDEFAULTS/pre_exec"
|
||||||
CPOSTEXEC="$CDEFAULTS/post_exec"
|
CPOSTEXEC="$CDEFAULTS/post_exec"
|
||||||
|
|
||||||
TMP=$(mktemp /tmp/$(basename $0).XXXXXX)
|
TMP=$(mktemp /tmp/$(basename $0).XXXXXX)
|
||||||
VERSION=0.5.2
|
VERSION=0.5.3
|
||||||
RELEASE="2007-01-27"
|
RELEASE="2007-XX-XX"
|
||||||
HALF_VERSION="ccollect $VERSION"
|
HALF_VERSION="ccollect $VERSION"
|
||||||
FULL_VERSION="ccollect $VERSION ($RELEASE)"
|
FULL_VERSION="ccollect $VERSION ($RELEASE)"
|
||||||
|
|
||||||
|
@ -63,10 +63,10 @@ usage()
|
||||||
echo ""
|
echo ""
|
||||||
echo " -h, --help: Show this help screen"
|
echo " -h, --help: Show this help screen"
|
||||||
echo " -p, --parallel: Parallelise backup processes"
|
echo " -p, --parallel: Parallelise backup processes"
|
||||||
echo " -a, --all: Backup all sources specified in $CSOURCES"
|
echo " -a, --all: Backup all sources specified in ${CSOURCES}"
|
||||||
echo " -v, --verbose: Be very verbose (uses set -x)."
|
echo " -v, --verbose: Be very verbose (uses set -x)."
|
||||||
echo ""
|
echo ""
|
||||||
echo " This is version $VERSION, released on ${RELEASE}"
|
echo " This is version ${VERSION}, released on ${RELEASE}"
|
||||||
echo " (the first version was written on 2005-12-05 by Nico Schottelius)."
|
echo " (the first version was written on 2005-12-05 by Nico Schottelius)."
|
||||||
echo ""
|
echo ""
|
||||||
echo " Retrieve latest ccollect at http://unix.schottelius.org/ccollect/"
|
echo " Retrieve latest ccollect at http://unix.schottelius.org/ccollect/"
|
||||||
|
@ -81,26 +81,26 @@ if [ $# -lt 2 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# check for configuraton directory, FIXME: _exit_err
|
# check for configuraton directory
|
||||||
#
|
#
|
||||||
[ -d "$CCOLLECT_CONF" ] || _exit_err "No configuration found in " \
|
[ -d "${CCOLLECT_CONF}" ] || _exit_err "No configuration found in " \
|
||||||
"\"$CCOLLECT_CONF\" (is \$CCOLLECT_CONF properly set?)"
|
"\"$CCOLLECT_CONF\" (is \$CCOLLECT_CONF properly set?)"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Filter arguments
|
# Filter arguments
|
||||||
#
|
#
|
||||||
INTERVAL=$1; shift
|
INTERVAL="$1"; shift
|
||||||
i=1
|
i=1
|
||||||
no_sources=0
|
no_sources=0
|
||||||
|
|
||||||
while [ $i -le $# ]; do
|
while [ "$i" -le $# ]; do
|
||||||
eval arg=\$$i
|
eval arg=\"\$$i\"
|
||||||
|
|
||||||
if [ "$NO_MORE_ARGS" = 1 ]; then
|
if [ "$NO_MORE_ARGS" = 1 ]; then
|
||||||
eval source_${no_sources}=\"$arg\"
|
eval source_${no_sources}=\"$arg\"
|
||||||
no_sources=$(($no_sources+1))
|
no_sources=$(($no_sources+1))
|
||||||
else
|
else
|
||||||
case $arg in
|
case "$arg" in
|
||||||
-a|--all)
|
-a|--all)
|
||||||
ALL=1
|
ALL=1
|
||||||
;;
|
;;
|
||||||
|
@ -136,17 +136,12 @@ fi
|
||||||
#
|
#
|
||||||
# Look for pre-exec command (general)
|
# Look for pre-exec command (general)
|
||||||
#
|
#
|
||||||
if [ -x "$CPREEXEC" ]; then
|
if [ -x "${CPREEXEC}" ]; then
|
||||||
echo "Executing $CPREEXEC ..."
|
echo "Executing ${CPREEXEC} ..."
|
||||||
"$CPREEXEC"
|
"${CPREEXEC}"; ret=$?
|
||||||
ret=$?
|
|
||||||
echo "Finished ${CPREEXEC}."
|
echo "Finished ${CPREEXEC}."
|
||||||
|
|
||||||
# FIXME: _exit_err
|
[ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed, not starting backup."
|
||||||
if [ $ret -ne 0 ]; then
|
|
||||||
echo "$CPREEXEC failed, not starting backup."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -160,18 +155,14 @@ if [ "$ALL" = 1 ]; then
|
||||||
# get entries from sources
|
# get entries from sources
|
||||||
#
|
#
|
||||||
cwd=$(pwd -P)
|
cwd=$(pwd -P)
|
||||||
( cd "$CSOURCES" && ls > "$TMP" )
|
( cd "${CSOURCES}" && ls > "${TMP}" )
|
||||||
|
|
||||||
# FIXME: _exit_err
|
[ "$?" -eq 0 ] || _exit_err "Listing of sources failed. Aborting."
|
||||||
if [ "$?" -ne 0 ]; then
|
|
||||||
echo "Listing of sources failed. Aborting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
while read tmp; do
|
while read tmp; do
|
||||||
eval source_${no_sources}=\"$tmp\"
|
eval source_${no_sources}=\"$tmp\"
|
||||||
no_sources=$(($no_sources+1))
|
no_sources=$(($no_sources+1))
|
||||||
done < "$TMP"
|
done < "${TMP}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -187,8 +178,8 @@ fi
|
||||||
# check default configuration
|
# check default configuration
|
||||||
#
|
#
|
||||||
|
|
||||||
D_FILE_INTERVAL="$CDEFAULTS/intervals/$INTERVAL"
|
D_FILE_INTERVAL="${CDEFAULTS}/intervals/${INTERVAL}"
|
||||||
D_INTERVAL=$(cat "$D_FILE_INTERVAL" 2>/dev/null)
|
D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Let's do the backup
|
# Let's do the backup
|
||||||
|
@ -207,8 +198,8 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
#
|
#
|
||||||
# start ourself, if we want parallel execution
|
# start ourself, if we want parallel execution
|
||||||
#
|
#
|
||||||
if [ "$PARALLEL" ]; then
|
if [ "${PARALLEL}" ]; then
|
||||||
"$0" "$INTERVAL" "$name" &
|
"$0" "${INTERVAL}" "${name}" &
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -224,24 +215,26 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
#
|
#
|
||||||
# Standard locations
|
# Standard locations
|
||||||
#
|
#
|
||||||
backup="$CSOURCES/$name"
|
backup="${CSOURCES}/${name}"
|
||||||
c_source="$backup/source"
|
c_source="${backup}/source"
|
||||||
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_vverbose="$backup/very_verbose"
|
c_vverbose="${backup}/very_verbose"
|
||||||
c_rsync_extra="$backup/rsync_options"
|
c_rsync_extra="${backup}/rsync_options"
|
||||||
c_summary="$backup/summary"
|
c_summary="${backup}/summary"
|
||||||
|
c_pre_exec="${backup}/pre_exec"
|
||||||
|
c_post_exec="${backup}/post_exec"
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# FIXME: enable in 0.6
|
# FIXME: enable in 0.6
|
||||||
|
# Always execute, warn if it exists in normal case
|
||||||
|
# and rm -rf the old backup, if "delete_incomplete" is set
|
||||||
#
|
#
|
||||||
#c_incomplete="$backup/incomplete_remove"
|
c_incomplete="$backup/delete_incomplete"
|
||||||
#c_marker=".ccollect-${CDATE}.$$"
|
#c_marker=".ccollect-${CDATE}.$$"
|
||||||
|
|
||||||
c_pre_exec="$backup/pre_exec"
|
|
||||||
c_post_exec="$backup/post_exec"
|
|
||||||
|
|
||||||
begin=$($DDATE)
|
begin=$($DDATE)
|
||||||
begin_s=$(date +%s)
|
begin_s=$(date +%s)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue