added config options for restic

This commit is contained in:
Paul Wilde 2024-08-23 10:12:00 +01:00
parent aad6bf38d3
commit f142e7b1cf
9 changed files with 62 additions and 30 deletions

View file

@ -16,10 +16,6 @@ proc parseSourceDirectories*(in_conf: TomlValueRef): seq[string] =
norg_config.source_directories.add(dir.getStr())
return src_dirs
proc parseEncryption*(enc_conf: TomlValueRef) =
setEncryptionPassphrase(enc_conf{"encryption_passphrase"}.getStr(""))
setEncryptionPassphraseFD(enc_conf{"encryption_passphrase_fd"}.getStr(""))
setEncryptionPassCommand(enc_conf{"encryption_passcommand"}.getStr(""))
proc parseRepositories*(rep_conf: TomlValueRef): seq[Repository] =
var repos: seq[Repository] = @[]
@ -28,15 +24,25 @@ proc parseRepositories*(rep_conf: TomlValueRef): seq[Repository] =
var repo = Repository()
repo.path = rtable["path"].getStr()
repo.label = rtable["label"].getStr()
if rtable.hasKey("tool"):
repo.tool = rtable["tool"].getStr("borg").toBackupTool()
repos.add(repo)
echo repos
return repos
proc parseEncryption*(enc_conf: TomlValueRef) =
setEncryptionPassphrase(enc_conf{"encryption_passphrase"}.getStr(""))
setEncryptionPassphraseFD(enc_conf{"encryption_passphrase_fd"}.getStr(""))
setEncryptionPassphraseFile(enc_conf{"encryption_passphrase_file"}.getStr(""))
setEncryptionPassCommand(enc_conf{"encryption_passcommand"}.getStr(""))
proc parseConfigFile*(file: string): NorgConfig =
norg_config = newNorgConfig()
let in_conf = parsetoml.parseFile(file)
norg_config.source_directories = parseSourceDirectories(in_conf)
parseEncryption(in_conf{"encryption"})
norg_config.repositories = parseRepositories(in_conf{"repositories"})
parseEncryption(in_conf{"encryption"})
norg_config.notifiers = parseNotifiers(in_conf)
norg_config.actions = parseActions(in_conf{"actions"})
norg_config.maintenance = parseMaintenance(in_conf{"maintenance"})

View file

@ -3,16 +3,25 @@ import os
proc setEncryptionPassphrase*(pw: string) =
if pw != "":
putEnv("BORG_PASSPHRASE", pw)
putEnv("RESTIC_PASSWORD", pw)
proc setEncryptionPassphraseFD*(pw: string) =
if pw != "":
putEnv("BORG_PASSPHRASE_FD", pw)
proc setEncryptionPassphraseFile*(pw: string) =
if pw != "":
putEnv("RESTIC_PASSWORD_FILE", pw)
proc setEncryptionPassCommand*(pw: string) =
if pw != "":
putEnv("BORG_PASSCOMMAND", pw)
putEnv("RESTIC_PASSWORD_COMMAND", pw)
proc delEncryptionPassphraseInfo*() =
delEnv("BORG_PASSPHRASE")
delEnv("BORG_PASSPHRASE_FD")
delEnv("BORG_PASSCOMMAND")
delEnv("RESTIC_PASSWORD")
delEnv("RESTIC_PASSWORD_FILE")
delEnv("RESTIC_PASSWORD_COMMAND")

View file

@ -5,5 +5,6 @@ type
RESTIC = "restic"
proc toBackupTool*(str: string): BackupTool =
for cmd in BackupTool.items:
if str == $cmd: return cmd
for tool in BackupTool.items:
if str == $tool: return tool
return BORG

6
norg/restic/backup.nim Normal file
View file

@ -0,0 +1,6 @@
import ../model/config_type
proc createBackup*(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented"
discard

5
norg/restic/extract.nim Normal file
View file

@ -0,0 +1,5 @@
import ../model/config_type
proc extractArchive*(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented"
discard

6
norg/restic/init.nim Normal file
View file

@ -0,0 +1,6 @@
import ../model/config_type
proc initRepo*(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented"
discard

7
norg/restic/list.nim Normal file
View file

@ -0,0 +1,7 @@
import ../model/config_type
proc listArchives*(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented"
discard

10
norg/restic/mount.nim Normal file
View file

@ -0,0 +1,10 @@
import ../model/config_type
proc mountArchive*(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented"
discard
proc unmountArchive*(nc: NorgConfig): int =
echo "Not Yet Implemented"
discard

View file

@ -1,29 +1,11 @@
import ../model/config_type
import ../utils/actions
proc initRepo*(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented"
discard
proc createBackup*(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented"
discard
proc listArchives*(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented"
discard
proc mountArchive*(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented"
discard
proc unmountArchive*(nc: NorgConfig): int =
echo "Not Yet Implemented"
discard
proc extractArchive*(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented"
discard
import init
import backup
import list
import mount
import extract
proc execute*(nc: NorgConfig, repo: Repository) =
case nc.args.command