2024-08-23 10:50:53 +02:00
|
|
|
import ../model/config_type
|
|
|
|
import ../utils/actions
|
|
|
|
|
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
|
|
|
|
|
|
|
proc execute*(nc: NorgConfig, repo: Repository) =
|
|
|
|
case nc.args.command
|
|
|
|
of INIT:
|
2024-08-23 13:04:27 +02:00
|
|
|
echo "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-23 13:04:27 +02:00
|
|
|
echo "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-23 13:04:27 +02:00
|
|
|
echo "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-23 13:04:27 +02:00
|
|
|
echo "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-23 13:31:43 +02:00
|
|
|
echo "Restoring snapshot from ", repo.label
|
|
|
|
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-23 13:04:27 +02:00
|
|
|
echo "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 10:50:53 +02:00
|
|
|
else:
|
|
|
|
discard
|