Cosmetic changes (III)
This commit is contained in:
parent
7678d4fb3f
commit
c3312ea54d
1 changed files with 37 additions and 29 deletions
66
ccollect.sh
66
ccollect.sh
|
@ -64,7 +64,7 @@ usage()
|
||||||
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)."
|
||||||
|
@ -247,12 +247,12 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
VERBOSE=""
|
VERBOSE=""
|
||||||
VVERBOSE=""
|
VVERBOSE=""
|
||||||
|
|
||||||
echo "$begin Beginning to backup"
|
echo "${begin} Beginning to backup"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Standard configuration checks
|
# Standard configuration checks
|
||||||
#
|
#
|
||||||
if [ ! -e "$backup" ]; then
|
if [ ! -e "${backup}" ]; then
|
||||||
echo "Source does not exist."
|
echo "Source does not exist."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -260,8 +260,8 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
#
|
#
|
||||||
# configuration _must_ be a directory
|
# 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
|
||||||
|
|
||||||
|
@ -269,14 +269,14 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
# first execute pre_exec, which may generate destination or other
|
# first execute pre_exec, which may generate destination or other
|
||||||
# parameters
|
# parameters
|
||||||
#
|
#
|
||||||
if [ -x "$c_pre_exec" ]; then
|
if [ -x "${c_pre_exec}" ]; then
|
||||||
echo "Executing ${c_pre_exec} ..."
|
echo "Executing ${c_pre_exec} ..."
|
||||||
"$c_pre_exec"
|
"${c_pre_exec}"; ret="$?"
|
||||||
ret="$?"
|
|
||||||
echo "Finished ${c_pre_exec}."
|
echo "Finished ${c_pre_exec}."
|
||||||
|
|
||||||
if [ "$ret" -ne 0 ]; then
|
# FIXME: is _exit_err senseful here?
|
||||||
echo "$c_pre_exec failed. Skipping."
|
if [ "${ret}" -ne 0 ]; then
|
||||||
|
echo "${c_pre_exec} failed. Skipping."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -284,13 +284,14 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
#
|
#
|
||||||
# interval definition: First try source specific, fallback to default
|
# interval definition: First try source specific, fallback to default
|
||||||
#
|
#
|
||||||
c_interval="$(cat "$backup/intervals/$INTERVAL" 2>/dev/null)"
|
c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)"
|
||||||
|
|
||||||
if [ -z "$c_interval" ]; then
|
if [ -z "${c_interval}" ]; then
|
||||||
c_interval="$D_INTERVAL"
|
c_interval="${D_INTERVAL}"
|
||||||
|
|
||||||
if [ -z "$c_interval" ]; then
|
# FIXME: is _exit_err senseful here?
|
||||||
echo "No definition for interval \"$INTERVAL\" found. Skipping."
|
if [ -z "${c_interval}" ]; then
|
||||||
|
echo "No definition for interval \"${INTERVAL}\" found. Skipping."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -298,8 +299,9 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
#
|
#
|
||||||
# Source checks
|
# Source checks
|
||||||
#
|
#
|
||||||
if [ ! -f "$c_source" ]; then
|
# FIXME: is _exit_err senseful here?
|
||||||
echo "Source description $c_source is not a file. Skipping."
|
if [ ! -f "${c_source}" ]; then
|
||||||
|
echo "Source description ${c_source} is not a file. Skipping."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
source=$(cat "$c_source")
|
source=$(cat "$c_source")
|
||||||
|
@ -312,8 +314,8 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
#
|
#
|
||||||
# destination _must_ be a directory
|
# destination _must_ be a directory
|
||||||
#
|
#
|
||||||
if [ ! -d "$c_dest" ]; then
|
if [ ! -d "${c_dest}" ]; then
|
||||||
echo "Destination $c_dest neither links to nor is a directory. Skipping."
|
echo "Destination ${c_dest} neither links to nor is a directory. Skipping."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -329,28 +331,28 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
#
|
#
|
||||||
# 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"
|
||||||
fi
|
fi
|
||||||
|
@ -363,6 +365,7 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
# # FIXME: Define which is the last dir before? Or put this thing into
|
# # FIXME: Define which is the last dir before? Or put this thing into
|
||||||
# # a while loop? Is it senseful to remove _ALL_ backups if non is complete?
|
# # a while loop? Is it senseful to remove _ALL_ backups if non is complete?
|
||||||
# if [ -f "$c_incomplete" ]; then
|
# if [ -f "$c_incomplete" ]; then
|
||||||
|
# echo "Searching for incomplete backups..."
|
||||||
# last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1)
|
# last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1)
|
||||||
#
|
#
|
||||||
# # check whether the last backup was incomplete
|
# # check whether the last backup was incomplete
|
||||||
|
@ -382,12 +385,17 @@ 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
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# FIXME: really do fuzzy matching here?
|
||||||
|
# or simply declare "everything of that directory (which is a directory) is
|
||||||
|
# a ccollect-backiup directory"?
|
||||||
# the created directories are named $INTERVAL-$DATE-$TIME.$PID
|
# the created directories are named $INTERVAL-$DATE-$TIME.$PID
|
||||||
count=$(cd "$c_dest" && ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l | sed 's/^ *//g')
|
count=$(cd "${c_dest}" && ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l | sed 's/^ *//g')
|
||||||
echo -n "Currently $count backup(s) exist(s),"
|
# FIXME: check return value
|
||||||
echo " total keeping $c_interval backup(s)."
|
echo -n "Currently ${count} backup(s) exist(s),"
|
||||||
|
echo " total keeping ${c_interval} backup(s)."
|
||||||
if [ "$count" -ge "$c_interval" ]; then
|
|
||||||
|
# STOPPED!
|
||||||
|
if [ "${count}" -ge "${c_interval}" ]; then
|
||||||
substract=$((${c_interval} - 1))
|
substract=$((${c_interval} - 1))
|
||||||
remove=$(($count - $substract))
|
remove=$(($count - $substract))
|
||||||
echo "Removing $remove backup(s)..."
|
echo "Removing $remove backup(s)..."
|
||||||
|
|
Loading…
Reference in a new issue