implement --no-snapshots-ok flag
This commit is contained in:
parent
59619ef433
commit
4e50ae25da
@ -71,7 +71,11 @@ def cmd_restore(args, parser):
|
||||
snapshot = get_newest_snapshot(args.name, config)
|
||||
|
||||
if not snapshot:
|
||||
return die("no snapshots found")
|
||||
if args.no_snapshots_ok:
|
||||
print("no snapshots found, but exiting OK")
|
||||
return
|
||||
else:
|
||||
return die("no snapshots found")
|
||||
|
||||
os.chdir(config.backup.path)
|
||||
with ExecWrapper(post=config.backup.restore_postexec):
|
||||
@ -138,8 +142,8 @@ def main():
|
||||
p_restore.set_defaults(func=cmd_restore)
|
||||
p_restore.add_argument("name", help="name of backup to restore")
|
||||
# p_restore.add_argument("snapshot", nargs="?", help="id of snapshot to restore") # TODO
|
||||
# p_restore.add_argument('--no-snapshots-ok', action='store_true',
|
||||
# help='don\'t return an error if no snapshots are available to be restored')
|
||||
p_restore.add_argument('--no-snapshots-ok', action='store_true',
|
||||
help='don\'t return an error if no snapshots are available to be restored')
|
||||
|
||||
p_exec = sp_action.add_parser("exec", help="execute a restic command")
|
||||
p_exec.set_defaults(func=cmd_exec)
|
||||
|
@ -16,7 +16,7 @@ def pdie(popen):
|
||||
def checkp(popen):
|
||||
popen.wait()
|
||||
if popen.returncode != 0:
|
||||
die(rc=popen.returncode)
|
||||
die("command failed", rc=popen.returncode)
|
||||
return popen
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user