some restic prune fixes
This commit is contained in:
parent
9b16f9a3fa
commit
94068ea910
2 changed files with 14 additions and 12 deletions
|
@ -2,6 +2,7 @@ import strutils
|
||||||
import strformat
|
import strformat
|
||||||
|
|
||||||
import ../model/command_type
|
import ../model/command_type
|
||||||
|
import ../model/maintenance_type
|
||||||
import ../utils/run
|
import ../utils/run
|
||||||
export run
|
export run
|
||||||
|
|
||||||
|
@ -19,3 +20,15 @@ proc genForgetCommand*(cmd: string, repo: string, archive: string, further_args:
|
||||||
let args = further_args.join(" ")
|
let args = further_args.join(" ")
|
||||||
let cmd = fmt"{RESTIC_BIN} {cmd} -r {repo} {archive} {args}"
|
let cmd = fmt"{RESTIC_BIN} {cmd} -r {repo} {archive} {args}"
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
proc genPruneCommand*(repo: string, further_args: seq[string], maintenance: Maintenance): string =
|
||||||
|
let args = further_args.join(" ")
|
||||||
|
let cmd = fmt"""{RESTIC_BIN} forget --prune \
|
||||||
|
--keep-hourly {maintenance.keep_hourly} \
|
||||||
|
--keep-daily {maintenance.keep_daily} \
|
||||||
|
--keep-weekly {maintenance.keep_weekly} \
|
||||||
|
--keep-monthly {maintenance.keep_monthly} \
|
||||||
|
--keep-yearly {maintenance.keep_yearly} \
|
||||||
|
-r {repo} {args}
|
||||||
|
"""
|
||||||
|
return cmd
|
||||||
|
|
|
@ -1,21 +1,10 @@
|
||||||
import ../model/config_type
|
import ../model/config_type
|
||||||
|
|
||||||
import strformat
|
|
||||||
|
|
||||||
import execute
|
import execute
|
||||||
|
|
||||||
proc addPruneOptions(cmd: var string, maintenance: Maintenance) =
|
|
||||||
cmd = fmt"""{cmd} \
|
|
||||||
--keep-hourly {maintenance.keep_hourly} \
|
|
||||||
--keep-daily {maintenance.keep_daily} \
|
|
||||||
--keep-weekly {maintenance.keep_weekly} \
|
|
||||||
--keep-monthly {maintenance.keep_monthly} \
|
|
||||||
--keep-yearly {maintenance.keep_yearly} \
|
|
||||||
"""
|
|
||||||
|
|
||||||
proc pruneRepo*(nc: NorgConfig, repo: Repository): int =
|
proc pruneRepo*(nc: NorgConfig, repo: Repository): int =
|
||||||
var cmd = genCommand(cmd = "forget --prune", repo = repo.path, further_args = nc.args.further_args)
|
var cmd = genPruneCommand(repo = repo.path, further_args = nc.args.further_args, nc.maintenance)
|
||||||
cmd.addPruneOptions(nc.maintenance)
|
|
||||||
return run cmd
|
return run cmd
|
||||||
|
|
||||||
proc forgetSnapshot*(nc: NorgConfig, repo: Repository): int =
|
proc forgetSnapshot*(nc: NorgConfig, repo: Repository): int =
|
||||||
|
|
Loading…
Reference in a new issue