From cdd34a3416cd5c70c0334329eb6c0204f7c643bd Mon Sep 17 00:00:00 2001 From: skybeam Date: Sat, 14 Jan 2023 21:57:24 +0000 Subject: [PATCH 1/3] Allow interval per source to be overwritten to 0 to skip the source in this interval. This change allows to overwrite an interval to 0 for a specific source in order to skip it for this interval. This is useful if you have default intervals configured and you would like to skip certain sources for specific intervals. --- ccollect | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 8b8f9e5..5aaefe2 100755 --- a/ccollect +++ b/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 # 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 + _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 -- 2.45.2 From ebded3049a9081769f05e67a5f6802adf906e6ac Mon Sep 17 00:00:00 2001 From: skybeam Date: Sun, 15 Jan 2023 22:31:02 +0000 Subject: [PATCH 2/3] Update 'ccollect' --- ccollect | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 5aaefe2..86acec5 100755 --- a/ccollect +++ b/ccollect @@ -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}" -o ${c_interval} -le 0 ]; then + if [ -z "${ls_rm_exclude}" -o ${c_interval} -eq 0 ]; then # shellcheck disable=SC2010 ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" @@ -796,7 +796,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Skip backup of this source if interval is zero. # - if [ ${c_interval} -le 0 ]; then + if [ ${c_interval} -eq 0 ]; then _techo "Skipping backup for this interval." exit 0 fi -- 2.45.2 From 1cc921ad8630cf9d7bbefd2281e6853c1454d501 Mon Sep 17 00:00:00 2001 From: skybeam Date: Sun, 15 Jan 2023 23:32:27 +0000 Subject: [PATCH 3/3] Interval value of 0 to skip interval for speicific sources. Update documentation to specify that intervals with value 0 are valid to skip an interval explicitly for a given source. --- doc/ccollect.text | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index f075b9a..6aee365 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -339,6 +339,9 @@ Example: -------------------------------------------------------------------------------- This means to keep 28 daily backups, 12 monthly backups and 4 weekly. +If you set a value of 0 the interval will be skipped. This is useful mainly on +source level in order to skip a certain interval for a specific source. + General pre- and post-execution ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -420,6 +423,12 @@ Example: /home/nico/vpn -------------------------------------------------------------------------------- +You can overwrite a default interval at source level. Setting it to 0 will skip +this interval on a specific source allowing you to skip an interval for a +specific source only while keeping source-specific interval amounts (or default +values) for any other source. + + Default options ^^^^^^^^^^^^^^^ If you add '$CCOLLECT_CONF/defaults/`option_name`', the value will -- 2.45.2