norgbackup/norg/restic/mount.nim

20 lines
646 B
Nim
Raw Normal View History

2024-08-23 11:12:00 +02:00
import ../model/config_type
2024-08-23 11:30:36 +02:00
import execute
import strformat
2024-08-23 11:12:00 +02:00
2024-08-23 11:30:36 +02:00
proc mountSnapshot*(nc: NorgConfig, repo: Repository): int =
let snapshot = repo.path & "::" & nc.args.others[0]
let others = nc.args.others[1..^1]
let ok = runDiscard genCommand(cmd = "mount", repo = snapshot, others = others)
if ok == 0:
echo fmt"Mounted {snapshot} at {others[0]}"
else:
echo "Failed to mount ", snapshot
2024-08-23 11:12:00 +02:00
2024-08-23 11:30:36 +02:00
proc unmountSnapshot*(nc: NorgConfig): int =
let ok = runDiscard genCommand(cmd = "umount", repo = "", others = nc.args.others)
if ok == 0:
echo "Unmounted ", nc.args.others[0]
else:
echo "Failed to unmount ", nc.args.others[0]