added option to set repo as append only so prune does not run

This commit is contained in:
Paul Wilde 2024-08-27 21:50:02 +01:00
parent d5eecc199f
commit 2e2e0dde82
4 changed files with 7 additions and 2 deletions

View file

@ -38,7 +38,8 @@ proc createBackup*(nc: NorgConfig, repo: Repository): int =
let total = (end_time - start_time).inMilliSeconds() let total = (end_time - start_time).inMilliSeconds()
case res case res
of 0: of 0:
discard pruneRepo(nc, repo) if not repo.append_only:
discard pruneRepo(nc, repo)
notify(nc.notifiers, state=Success, runtime=total) notify(nc.notifiers, state=Success, runtime=total)
of 1: of 1:
notify(nc.notifiers, state=Failure, runtime=total) notify(nc.notifiers, state=Failure, runtime=total)

View file

@ -28,6 +28,8 @@ proc parseRepositories*(rep_conf: TomlValueRef): seq[Repository] =
var repo = Repository() var repo = Repository()
repo.path = rtable["path"].getStr() repo.path = rtable["path"].getStr()
repo.label = rtable["label"].getStr() repo.label = rtable["label"].getStr()
if rtable.hasKey("append_only"):
repo.append_only = rtable["append_only"].getBool()
if rtable.hasKey("tool"): if rtable.hasKey("tool"):
repo.tool = rtable["tool"].getStr("borg").toBackupTool() repo.tool = rtable["tool"].getStr("borg").toBackupTool()
repos.add(repo) repos.add(repo)

View file

@ -8,6 +8,7 @@ type
path*: string path*: string
label*: string label*: string
tool*: BackupTool tool*: BackupTool
append_only*: bool
proc findRepository*(repos: seq[Repository], r: string): seq[Repository] = proc findRepository*(repos: seq[Repository], r: string): seq[Repository] =
let repo = collect: let repo = collect:

View file

@ -27,7 +27,8 @@ proc createBackup*(nc: NorgConfig, repo: Repository): int =
let total = (end_time - start_time).inMilliSeconds() let total = (end_time - start_time).inMilliSeconds()
case res case res
of 0: of 0:
discard pruneRepo(nc, repo) if not repo.append_only:
discard pruneRepo(nc, repo)
notify(nc.notifiers, state=Success, runtime=total) notify(nc.notifiers, state=Success, runtime=total)
of 1: of 1:
notify(nc.notifiers, state=Failure, runtime=total) notify(nc.notifiers, state=Failure, runtime=total)