2024-08-16 17:40:24 +02:00
|
|
|
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-16 17:40:24 +02:00
|
|
|
|
2024-08-19 03:21:46 +02:00
|
|
|
import execute
|
|
|
|
import prune
|
|
|
|
import create
|
|
|
|
import mount
|
|
|
|
import extract
|
2024-08-16 17:40:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2024-08-16 17:40:24 +02:00
|
|
|
proc execute*(nc: NorgConfig) =
|
2024-08-18 19:45:37 +02:00
|
|
|
run_actions(norg_config.actions.before_everything)
|
2024-08-16 17:40:24 +02:00
|
|
|
for repo in nc.repositories:
|
2024-08-18 19:45:37 +02:00
|
|
|
run_actions(norg_config.actions.before_actions)
|
2024-08-16 17:40:24 +02:00
|
|
|
case nc.args.borg_cmd
|
2024-08-18 19:45:37 +02:00
|
|
|
of INIT:
|
2024-08-16 17:40:24 +02:00
|
|
|
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:
|
2024-08-16 17:40:24 +02:00
|
|
|
discard listArchives(nc, repo)
|
2024-08-18 19:45:37 +02:00
|
|
|
of MOUNT:
|
2024-08-16 17:40:24 +02:00
|
|
|
discard mountArchive(nc, repo)
|
2024-08-18 19:45:37 +02:00
|
|
|
of UMOUNT:
|
2024-08-16 17:40:24 +02:00
|
|
|
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)
|