From 27d127a861ae9707473b2eaf77bb39fe5350fd8e Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Wed, 29 Jul 2026 11:42:42 -0700 Subject: allow empty retain setting to keep all backups --- backomp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backomp b/backomp index c811a2a..f955916 100755 --- a/backomp +++ b/backomp @@ -42,11 +42,11 @@ BEGIN { wshift = (11 - arr2[opt_week_start])*24*60*60 } -NR == 1 { +!n_buckets || NR == 1 { ++keep[$0] } -{ +n_buckets { t = mktime(gensub(/(.*\/|^)(.+)-(..)-(..)-(..)(..)(..)$/, "\\2 \\3 \\4 \\5 \\6 \\7", 1), 1) if (t < 0) { @@ -354,7 +354,7 @@ backup() { dest_path="${dest_dir}/$(date -u '+%Y-%m-%d-%H%M%S')" copy "${src_path}" "${dest_path}" "${snaps[0]}" || return 1 - if [[ ! "${retain}" =~ ^( *([0-9]+|\*)\^?[hdwM] *)+$ ]]; then + if [[ ! "${retain}" =~ ^( *([0-9]+|\*)\^?[hdwM])*\ *$ ]]; then err "invalid \$retain setting: ${retain}" return 1 fi @@ -369,13 +369,14 @@ backup() { } declare -A def_opts=( - ['retain']='*h' # e.g. 24h7d4w12M or 24^h10d*M + ['retain']= # e.g. *h or 24h7d4w12M or 24^h10d*M ['interval']='0' ['week_start']='mon' ['rsync_flags']='-a' ['rclone_flags']='--sftp-copy-is-hardlink' ['rclone_copy_command']='copy' ['rclone_use_copy_dest']=1 + ['pre_copy']= ) declare -A opts tainted_opts reset_opts() { -- cgit v1.3.1