removed risk of restic failing is --stats flag is passed
This commit is contained in:
parent
948639b9d5
commit
59dead5ea5
4 changed files with 12 additions and 1 deletions
|
@ -18,7 +18,7 @@ proc genArchiveName(): string =
|
|||
|
||||
proc createArchive(nc: NorgConfig, repo: Repository, archivename: string, retry: int = 0): int =
|
||||
let further_args = concat(nc.source_directories, nc.args.further_args)
|
||||
let res = run genCommand(cmd = "create", repo = archivename, further_args = further_args)
|
||||
let res = run genCreateCommand(cmd = "create", repo = archivename, stats=nc.args.stats, further_args = further_args)
|
||||
if res != 0:
|
||||
sleep 15 * 1000 # 15 seconds
|
||||
if retry == nc.retries:
|
||||
|
|
|
@ -10,6 +10,13 @@ proc genCommand*(cmd: string, repo: string, further_args: seq[string]): string =
|
|||
let cmd = fmt"{BORG_BIN} {cmd} {repo} {args}"
|
||||
return cmd
|
||||
|
||||
proc genCreateCommand*(cmd: string, repo: string, stats: bool, further_args: seq[string]): string =
|
||||
let args = further_args.join(" ")
|
||||
var stats_flag = "--stats"
|
||||
if not stats: stats_flag = ""
|
||||
let cmd = fmt"{BORG_BIN} {cmd} {stats_flag} {repo} {args}"
|
||||
return cmd
|
||||
|
||||
proc genDeleteCommand*(cmd: string, repo: string, archive: string, further_args: seq[string]): string =
|
||||
let args = further_args.join(" ")
|
||||
let cmd = fmt"{BORG_BIN} {cmd} {repo} {archive} {args}"
|
||||
|
|
|
@ -8,6 +8,7 @@ type
|
|||
command*: Command
|
||||
repository*: string
|
||||
archive*: string
|
||||
stats*: bool
|
||||
further_args*: seq[string]
|
||||
|
||||
var norg_args*: NorgArgs = NorgArgs()
|
||||
|
@ -19,6 +20,7 @@ proc parseArgs*() =
|
|||
option("-d", "--destination", help="Destination when extracting backup", required = false)
|
||||
option("-r", "--repository", help="Define an explicit repository to work on by either label or path.", required = false)
|
||||
option("-a", "--archive", help="The archive or snapshot to operate on", required = false)
|
||||
flag("-s","--stats",help="Provides statistics at the end of a backup (Borg only)")
|
||||
arg("command", help="The command to run, defaults to 'create' which will perform a backup.", default=some("create"))
|
||||
arg("further_args", nargs = -1, help="Any further arguments to send onto borg or restic.")
|
||||
try:
|
||||
|
@ -28,6 +30,7 @@ proc parseArgs*() =
|
|||
norg_args.command = opts.command.toCommand()
|
||||
norg_args.repository = opts.repository
|
||||
norg_args.archive = opts.archive
|
||||
norg_args.stats = opts.stats
|
||||
norg_args.further_args = opts.further_args
|
||||
except ShortCircuit as err:
|
||||
if err.flag == "argparse_help":
|
||||
|
|
1
todo.md
1
todo.md
|
@ -8,4 +8,5 @@
|
|||
- [x] Allow to specify direct repository so mount/extract doesn't fail if multiple are available
|
||||
- [ ] Better workflow of using borg flags and options as it seems a little sketchy just passing them through to the command string
|
||||
- [ ] Add Windows support (Restic Only)
|
||||
- [ ] Include/Exclude files functionality
|
||||
- [ ] ... and loads more
|
||||
|
|
Loading…
Reference in a new issue