Allow interval per source to be overwritten to 0 to skip the source in this interval. #2
1 changed files with 10 additions and 2 deletions
12
ccollect
12
ccollect
|
@ -765,7 +765,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do
|
|||
oldest_bak=$(ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n 1 || \
|
||||
_exit_err "Listing oldest backup failed")
|
||||
_techo "Using ${oldest_bak} for destination dir ${destination_dir}"
|
||||
if mv "${oldest_bak}" "${destination_dir}"; then
|
||||
if mv "${oldest_bak}" "${destination_dir}" 2>/dev/null; then
|
||||
|
||||
# Touch dest dir so it is not sorted wrong in listings below.
|
||||
ls_rm_exclude=$(basename "${destination_dir}")
|
||||
|
||||
|
@ -779,7 +779,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do
|
|||
if [ "${remove}" -gt 0 ]; then
|
||||
_techo "Removing ${remove} backup(s)..."
|
||||
|
||||
if [ -z "${ls_rm_exclude}" ]; then
|
||||
if [ -z "${ls_rm_exclude}" -o ${c_interval} -le 0 ]; then
|
||||
nico
commented
If we want to match 0, we should do If we want to match 0, we should do `-eq 0`, otherwise the documentation will need to be adjusted.
skybeam
commented
Fine with me, usually errors are positive integers and I learned never ever to match numbers with "eq" - but for integers here it might be ok, so feel free to use -eq. Fine with me, usually errors are positive integers and I learned never ever to match numbers with "eq" - but for integers here it might be ok, so feel free to use -eq.
|
||||
# shellcheck disable=SC2010
|
||||
ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \
|
||||
_exit_err "Listing old backups failed"
|
||||
|
@ -793,6 +793,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do
|
|||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Skip backup of this source if interval is zero.
|
||||
#
|
||||
if [ ${c_interval} -le 0 ]; then
|
||||
nico
commented
Same here Same here
|
||||
_techo "Skipping backup for this interval."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for backup directory to clone from: Always clone from the latest one!
|
||||
# Exclude destination_dir from listing, it can be touched reused and renamed
|
||||
|
|
Loading…
Reference in a new issue
Why skip potential error messages?
Because oldest_bak can be empty and this causing mv to spit an error - which is OK as we are only interested in the return code telling us if the move was successful. In this case the failed move is expected. No need for an error message.