2024-08-23 10:50:53 +02:00
|
|
|
import ../model/config_type
|
|
|
|
import ../utils/actions
|
2024-08-27 22:39:21 +02:00
|
|
|
import ../model/log_type
|
2024-08-23 10:50:53 +02:00
|
|
|
|
2024-08-23 11:12:00 +02:00
|
|
|
import init
|
|
|
|
import backup
|
|
|
|
import list
|
|
|
|
import mount
|
2024-08-23 13:31:43 +02:00
|
|
|
import restore
|
2024-08-23 11:30:36 +02:00
|
|
|
import prune
|
2024-08-23 10:50:53 +02:00
|
|
|
|
2024-08-27 22:16:31 +02:00
|
|
|
|
2024-08-23 10:50:53 +02:00
|
|
|
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
|
2024-08-23 10:50:53 +02:00
|
|
|
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
|
2024-08-23 10:50:53 +02:00
|
|
|
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)
|
2024-08-23 10:50:53 +02:00
|
|
|
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)
|
2024-08-23 10:50:53 +02:00
|
|
|
of EXTRACT:
|
|
|
|
run_actions(norg_config.actions.before_extract)
|
2024-08-27 22:16:31 +02:00
|
|
|
info "Restoring snapshot from ", repo.label
|
2024-08-23 13:31:43 +02:00
|
|
|
discard restoreSnapshot(nc, repo)
|
2024-08-23 10:50:53 +02:00
|
|
|
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)
|
2024-08-23 10:50:53 +02:00
|
|
|
else:
|
|
|
|
discard
|