mirror of
https://github.com/psy0rz/zfs_autobackup.git
synced 2025-06-17 02:30:58 +03:00
move exclude_paths and exclude_received to common
This commit is contained in:
parent
14d45667de
commit
033fcf68f7
@ -19,6 +19,8 @@ class ZfsAuto(object):
|
|||||||
if print_arguments:
|
if print_arguments:
|
||||||
print("ARGUMENTS: " + " ".join(argv))
|
print("ARGUMENTS: " + " ".join(argv))
|
||||||
|
|
||||||
|
|
||||||
|
self.exclude_paths = []
|
||||||
self.args = self.parse_args(argv)
|
self.args = self.parse_args(argv)
|
||||||
|
|
||||||
def parse_args(self, argv):
|
def parse_args(self, argv):
|
||||||
@ -44,6 +46,7 @@ class ZfsAuto(object):
|
|||||||
self.log = LogConsole(show_debug=args.debug, show_verbose=args.verbose, color=sys.stdout.isatty())
|
self.log = LogConsole(show_debug=args.debug, show_verbose=args.verbose, color=sys.stdout.isatty())
|
||||||
|
|
||||||
self.verbose(self.HEADER)
|
self.verbose(self.HEADER)
|
||||||
|
self.verbose("")
|
||||||
|
|
||||||
if args.backup_name == None:
|
if args.backup_name == None:
|
||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
@ -58,6 +61,21 @@ class ZfsAuto(object):
|
|||||||
self.warning("--ignore-replicated has been renamed, using --exclude-unchanged")
|
self.warning("--ignore-replicated has been renamed, using --exclude-unchanged")
|
||||||
args.exclude_unchanged = True
|
args.exclude_unchanged = True
|
||||||
|
|
||||||
|
# Note: Before version v3.1-beta5, we always used exclude_received. This was a problem if you wanted to
|
||||||
|
# replicate an existing backup to another host and use the same backupname/snapshots. However, exclude_received
|
||||||
|
# may still need to be used to explicitly exclude a backup with the 'received' source property to avoid accidental
|
||||||
|
# recursive replication of a zvol that is currently being received in another session (as it will have changes).
|
||||||
|
|
||||||
|
args.exclude_paths = [] # not an actual arg, but depending on args so whatever :)
|
||||||
|
if args.ssh_source == args.ssh_target:
|
||||||
|
if args.target_path:
|
||||||
|
# target and source are the same, make sure to exclude target_path
|
||||||
|
self.verbose("NOTE: Source and target are on the same host, excluding target-path from selection.")
|
||||||
|
args.exclude_paths.append(args.target_path)
|
||||||
|
else:
|
||||||
|
self.verbose("NOTE: Source and target are on the same host, excluding received datasets from selection.")
|
||||||
|
args.exclude_received = True
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def get_parser(self):
|
def get_parser(self):
|
||||||
|
@ -16,9 +16,13 @@ class ZfsAutobackup(ZfsAuto):
|
|||||||
|
|
||||||
|
|
||||||
def __init__(self, argv, print_arguments=True):
|
def __init__(self, argv, print_arguments=True):
|
||||||
|
|
||||||
|
# NOTE: common options and parameters are in ZfsAuto
|
||||||
super(ZfsAutobackup, self).__init__(argv, print_arguments)
|
super(ZfsAutobackup, self).__init__(argv, print_arguments)
|
||||||
|
|
||||||
def parse_args(self, argv):
|
def parse_args(self, argv):
|
||||||
|
"""do extra checks on common args"""
|
||||||
|
|
||||||
args=super(ZfsAutobackup, self).parse_args(argv)
|
args=super(ZfsAutobackup, self).parse_args(argv)
|
||||||
|
|
||||||
if args.allow_empty:
|
if args.allow_empty:
|
||||||
@ -424,24 +428,8 @@ class ZfsAutobackup(ZfsAuto):
|
|||||||
|
|
||||||
################# select source datasets
|
################# select source datasets
|
||||||
self.set_title("Selecting")
|
self.set_title("Selecting")
|
||||||
|
source_datasets = source_node.selected_datasets(property_name=property_name,exclude_received=self.args.exclude_received,
|
||||||
# Note: Before version v3.1-beta5, we always used exclude_received. This was a problem if you wanted to
|
exclude_paths=self.args.exclude_paths,
|
||||||
# replicate an existing backup to another host and use the same backupname/snapshots. However, exclude_received
|
|
||||||
# may still need to be used to explicitly exclude a backup with the 'received' source property to avoid accidental
|
|
||||||
# recursive replication of a zvol that is currently being received in another session (as it will have changes).
|
|
||||||
exclude_paths = []
|
|
||||||
exclude_received = self.args.exclude_received
|
|
||||||
if self.args.ssh_source == self.args.ssh_target:
|
|
||||||
if self.args.target_path:
|
|
||||||
# target and source are the same, make sure to exclude target_path
|
|
||||||
self.verbose("NOTE: Source and target are on the same host, excluding target-path from selection.")
|
|
||||||
exclude_paths.append(self.args.target_path)
|
|
||||||
else:
|
|
||||||
self.verbose("NOTE: Source and target are on the same host, excluding received datasets from selection.")
|
|
||||||
exclude_received = True
|
|
||||||
|
|
||||||
source_datasets = source_node.selected_datasets(property_name=property_name,exclude_received=exclude_received,
|
|
||||||
exclude_paths=exclude_paths,
|
|
||||||
exclude_unchanged=self.args.exclude_unchanged,
|
exclude_unchanged=self.args.exclude_unchanged,
|
||||||
min_change=self.args.min_change)
|
min_change=self.args.min_change)
|
||||||
if not source_datasets:
|
if not source_datasets:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user