norgbackup/norg/borg/borg.nim

63 lines
1.9 KiB
Nim
Raw Normal View History

import ../model/config_type
2024-08-19 03:21:46 +02:00
import ../model/encryption_type
2024-08-18 19:45:37 +02:00
import ../model/borg_type
import ../utils/actions
2024-08-19 03:21:46 +02:00
import execute
import prune
import create
import mount
import extract
proc initRepo(nc: NorgConfig, repo: Repository): int =
return runDiscard genCommand(cmd = "init", repo = repo.path, others = nc.args.others)
proc listArchives(nc: NorgConfig, repo: Repository): int =
return run genCommand(cmd = "list", repo = repo.path, others = nc.args.others)
2024-08-18 19:45:37 +02:00
proc compactRepo(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented."
discard
proc checkRepo(nc: NorgConfig, repo: Repository): int =
echo "Not Yet Implemented."
discard
proc execute*(nc: NorgConfig) =
2024-08-18 19:45:37 +02:00
run_actions(norg_config.actions.before_everything)
for repo in nc.repositories:
2024-08-18 19:45:37 +02:00
run_actions(norg_config.actions.before_actions)
case nc.args.borg_cmd
2024-08-18 19:45:37 +02:00
of INIT:
discard initRepo(nc, repo)
2024-08-18 19:45:37 +02:00
of CREATE:
run_actions(norg_config.actions.before_backup)
2024-08-19 03:21:46 +02:00
discard createBackup(nc, repo)
2024-08-18 19:45:37 +02:00
run_actions(norg_config.actions.after_backup)
of LIST:
discard listArchives(nc, repo)
2024-08-18 19:45:37 +02:00
of MOUNT:
discard mountArchive(nc, repo)
2024-08-18 19:45:37 +02:00
of UMOUNT:
discard unmountArchive(nc)
2024-08-18 19:45:37 +02:00
of EXTRACT:
run_actions(norg_config.actions.before_extract)
2024-08-18 16:43:11 +02:00
discard extractArchive(nc, repo)
2024-08-18 19:45:37 +02:00
run_actions(norg_config.actions.after_extract)
of PRUNE:
run_actions(norg_config.actions.before_prune)
discard pruneRepo(nc, repo)
run_actions(norg_config.actions.after_prune)
of COMPACT:
run_actions(norg_config.actions.before_compact)
discard compactRepo(nc, repo)
run_actions(norg_config.actions.after_compact)
of CHECK:
run_actions(norg_config.actions.before_check)
discard checkRepo(nc, repo)
run_actions(norg_config.actions.after_check)
run_actions(norg_config.actions.after_actions)
delEncryptionPassphraseInfo()
run_actions(norg_config.actions.after_everything)