implement --no-snapshots-ok flag

This commit is contained in:
dave 2023-05-15 21:55:03 -07:00
parent 59619ef433
commit 4e50ae25da
3 changed files with 9 additions and 5 deletions

View File

@ -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)

View File

@ -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

View File

@ -1,7 +1,7 @@
from setuptools import setup
__version__ = "0.0.0"
__version__ = "0.0.1"
setup(name='resticbackup',