From 2e2e0dde82c8319af0b71441886dea6310ea9920 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Tue, 27 Aug 2024 21:50:02 +0100 Subject: [PATCH] added option to set repo as append only so prune does not run --- norg/borg/create.nim | 3 ++- norg/config/init.nim | 2 ++ norg/model/repository_type.nim | 1 + norg/restic/backup.nim | 3 ++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/norg/borg/create.nim b/norg/borg/create.nim index fce9f58..30409d0 100644 --- a/norg/borg/create.nim +++ b/norg/borg/create.nim @@ -38,7 +38,8 @@ proc createBackup*(nc: NorgConfig, repo: Repository): int = let total = (end_time - start_time).inMilliSeconds() case res of 0: - discard pruneRepo(nc, repo) + if not repo.append_only: + discard pruneRepo(nc, repo) notify(nc.notifiers, state=Success, runtime=total) of 1: notify(nc.notifiers, state=Failure, runtime=total) diff --git a/norg/config/init.nim b/norg/config/init.nim index 87ab790..13d17c3 100644 --- a/norg/config/init.nim +++ b/norg/config/init.nim @@ -28,6 +28,8 @@ proc parseRepositories*(rep_conf: TomlValueRef): seq[Repository] = var repo = Repository() repo.path = rtable["path"].getStr() repo.label = rtable["label"].getStr() + if rtable.hasKey("append_only"): + repo.append_only = rtable["append_only"].getBool() if rtable.hasKey("tool"): repo.tool = rtable["tool"].getStr("borg").toBackupTool() repos.add(repo) diff --git a/norg/model/repository_type.nim b/norg/model/repository_type.nim index 0a0e279..fa0d277 100644 --- a/norg/model/repository_type.nim +++ b/norg/model/repository_type.nim @@ -8,6 +8,7 @@ type path*: string label*: string tool*: BackupTool + append_only*: bool proc findRepository*(repos: seq[Repository], r: string): seq[Repository] = let repo = collect: diff --git a/norg/restic/backup.nim b/norg/restic/backup.nim index 9210e24..e44ff0a 100644 --- a/norg/restic/backup.nim +++ b/norg/restic/backup.nim @@ -27,7 +27,8 @@ proc createBackup*(nc: NorgConfig, repo: Repository): int = let total = (end_time - start_time).inMilliSeconds() case res of 0: - discard pruneRepo(nc, repo) + if not repo.append_only: + discard pruneRepo(nc, repo) notify(nc.notifiers, state=Success, runtime=total) of 1: notify(nc.notifiers, state=Failure, runtime=total)