diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-08-07 03:08:31 -0700 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-08-07 03:08:31 -0700 |
| commit | 50b52937816cc549c289d17fdfa0e116afc672f7 (patch) | |
| tree | 995699e2af62f6cc1c197161e36d738346995e7f | |
| parent | e6b7124f9c375cf81b532040981077bde923ec32 (diff) | |
| download | backomp-50b52937816cc549c289d17fdfa0e116afc672f7.tar.gz backomp-50b52937816cc549c289d17fdfa0e116afc672f7.tar.xz | |
| -rwxr-xr-x | backomp | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -43,10 +43,12 @@ BEGIN { if ("w" in ret) after_w = ("M" in ret) ? "M" : "y" - split("mon tue wed thu fri sat sun", arr) - for (i in arr) - arr2[arr[i]] = i - 1 - wshift = (10 - arr2[opt_week_start])*24*60*60 + if (opt_week_start) { + split("mon tue wed thu fri sat sun", arr) + for (i in arr) + arr2[arr[i]] = i - 1 + wshift = (10 - arr2[opt_week_start])*24*60*60 + } } !n_buckets || keep_first && NR == 1 { @@ -59,8 +61,9 @@ n_buckets { bt["h"] = flr(t, 60*60) bt["d"] = flr(t, 24*60*60) - bt["w"] = flr(t + wshift, 7*24*60*60) - wshift bt["M"] = mstart(t) + d = wshift ? wshift : -bt["M"] + bt["w"] = flr(t + d, 7*24*60*60) - d bt["y"] = ystart(t) for (i = 1; i <= n_buckets; ++i) { @@ -380,6 +383,10 @@ backup() { err "invalid \$retain setting: ${retain}" return 1 fi + if [[ ! "${week_start}" =~ ^(|mon|tue|wed|thu|fri|sat|sun)$ ]]; then + err "invalid \$week_start setting: ${week_start}" + return 1 + fi if [[ -n "${dest_path}" ]]; then filter snaps snaps 'post-snapshot awk prefilter' \ @@ -395,7 +402,7 @@ backup() { declare -A def_opts=( ['retain']= # e.g. *h or 24h7d4w12M5y or 24^h10d*M ['interval']='0' - ['week_start']='mon' + ['week_start']='mon' # empty value aligns weeks to 1st of each month ['rsync_flags']='-a' ['rclone_flags']='--sftp-copy-is-hardlink' ['rclone_copy_command']='copy' |
