From 14d45667deadd116e7f3f29ecd09bf6d4d3d4599 Mon Sep 17 00:00:00 2001 From: Edwin Eefting Date: Mon, 17 Jan 2022 22:54:27 +0100 Subject: [PATCH] fixes --- zfs_autobackup/ZfsAuto.py | 28 +++++++++------------------ zfs_autobackup/ZfsAutobackup.py | 34 ++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/zfs_autobackup/ZfsAuto.py b/zfs_autobackup/ZfsAuto.py index e374552..1ecb79a 100644 --- a/zfs_autobackup/ZfsAuto.py +++ b/zfs_autobackup/ZfsAuto.py @@ -41,12 +41,6 @@ class ZfsAuto(object): if args.test: args.verbose = True - if args.allow_empty: - args.min_change = 0 - - if args.destroy_incompatible: - args.rollback = True - self.log = LogConsole(show_debug=args.debug, show_verbose=args.verbose, color=sys.stdout.isatty()) self.verbose(self.HEADER) @@ -56,23 +50,10 @@ class ZfsAuto(object): self.log.error("Please specify BACKUP-NAME") sys.exit(255) - if args.resume: - self.warning("The --resume option isn't needed anymore (its autodetected now)") - - if args.raw: - self.warning( - "The --raw option isn't needed anymore (its autodetected now). Also see --encrypt and --decrypt.") - if args.target_path is not None and args.target_path[0] == "/": self.log.error("Target should not start with a /") sys.exit(255) - if args.compress and args.ssh_source is None and args.ssh_target is None: - self.warning("Using compression, but transfer is local.") - - if args.compress and args.zfs_compressed: - self.warning("Using --compress with --zfs-compressed, might be inefficient.") - if args.ignore_replicated: self.warning("--ignore-replicated has been renamed, using --exclude-unchanged") args.exclude_unchanged = True @@ -117,6 +98,15 @@ class ZfsAuto(object): help='Target host to push backup to.') + group=parser.add_argument_group("Selection options") + group.add_argument('--ignore-replicated', action='store_true', help=argparse.SUPPRESS) + group.add_argument('--exclude-unchanged', action='store_true', + help='Exclude datasets that have no changes since any last snapshot. (Useful in combination with proxmox HA replication)') + group.add_argument('--exclude-received', action='store_true', + help='Exclude datasets that have the origin of their autobackup: property as "received". ' + 'This can avoid recursive replication between two backup partners.') + group.add_argument('--property-format', metavar='FORMAT', default="autobackup:{}", + help='Dataset selection string format. Default: %(default)s') return (parser) diff --git a/zfs_autobackup/ZfsAutobackup.py b/zfs_autobackup/ZfsAutobackup.py index 9a669de..17f3999 100644 --- a/zfs_autobackup/ZfsAutobackup.py +++ b/zfs_autobackup/ZfsAutobackup.py @@ -18,23 +18,35 @@ class ZfsAutobackup(ZfsAuto): def __init__(self, argv, print_arguments=True): super(ZfsAutobackup, self).__init__(argv, print_arguments) + def parse_args(self, argv): + args=super(ZfsAutobackup, self).parse_args(argv) + + if args.allow_empty: + args.min_change = 0 + + if args.destroy_incompatible: + args.rollback = True + + if args.resume: + self.warning("The --resume option isn't needed anymore (its autodetected now)") + + if args.raw: + self.warning( + "The --raw option isn't needed anymore (its autodetected now). Also see --encrypt and --decrypt.") + + if args.compress and args.ssh_source is None and args.ssh_target is None: + self.warning("Using compression, but transfer is local.") + + if args.compress and args.zfs_compressed: + self.warning("Using --compress with --zfs-compressed, might be inefficient.") + + return args def get_parser(self): """extend common parser with extra stuff needed for zfs-autobackup""" parser=super(ZfsAutobackup, self).get_parser() - - group=parser.add_argument_group("Selection options") - group.add_argument('--ignore-replicated', action='store_true', help=argparse.SUPPRESS) - group.add_argument('--exclude-unchanged', action='store_true', - help='Exclude datasets that have no changes since any last snapshot. (Useful in combination with proxmox HA replication)') - group.add_argument('--exclude-received', action='store_true', - help='Exclude datasets that have the origin of their autobackup: property as "received". ' - 'This can avoid recursive replication between two backup partners.') - group.add_argument('--property-format', metavar='FORMAT', default="autobackup:{}", - help='Dataset selection string format. Default: %(default)s') - group=parser.add_argument_group("Snapshot options") group.add_argument('--no-snapshot', action='store_true', help='Don\'t create new snapshots (useful for finishing uncompleted backups, or cleanups)')