norgbackup/norg/restic/restic.nim

44 lines
1.2 KiB
Nim
Raw Normal View History

import ../model/config_type
import ../utils/actions
2024-08-23 11:12:00 +02:00
import init
import backup
import list
import mount
import restore
2024-08-23 11:30:36 +02:00
import prune
2024-08-27 22:16:31 +02:00
import threadlogging
proc execute*(nc: NorgConfig, repo: Repository) =
case nc.args.command
of INIT:
2024-08-27 22:16:31 +02:00
info "Initializing repo: ", repo.label
discard initRepo(nc, repo)
of CREATE:
run_actions(norg_config.actions.before_backup)
2024-08-27 22:16:31 +02:00
info "Backing up to ", repo.label
discard createBackup(nc, repo)
run_actions(norg_config.actions.after_backup)
of LIST:
2024-08-27 22:16:31 +02:00
info "Listing Snapshots at ", repo.label
2024-08-23 11:30:36 +02:00
discard listSnapshots(nc, repo)
of MOUNT:
2024-08-27 22:16:31 +02:00
info "Mounting Snapshot from ", repo.label
2024-08-23 11:30:36 +02:00
discard mountSnapshot(nc, repo)
of EXTRACT:
run_actions(norg_config.actions.before_extract)
2024-08-27 22:16:31 +02:00
info "Restoring snapshot from ", repo.label
discard restoreSnapshot(nc, repo)
run_actions(norg_config.actions.after_extract)
2024-08-23 11:30:36 +02:00
of PRUNE:
run_actions(norg_config.actions.before_prune)
2024-08-27 22:16:31 +02:00
info "Pruning repo: ", repo.label
2024-08-23 11:30:36 +02:00
discard pruneRepo(nc, repo)
run_actions(norg_config.actions.after_prune)
2024-08-23 15:16:13 +02:00
of DELETE:
2024-08-27 22:16:31 +02:00
info "Forgetting snapshot: ", nc.args.archive
2024-08-23 15:16:13 +02:00
discard forgetSnapshot(nc, repo)
else:
discard