forked from third-party-mirrors/zfs_autobackup
only_received feature
This commit is contained in:
parent
81fa5c5bab
commit
4a1b9dfc26
@ -109,6 +109,8 @@ class ZfsAuto(CliBase):
|
||||
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('--only-received', action='store_true',
|
||||
help='Include only datasets that have the origin of their autobackup: property as "received".')
|
||||
group.add_argument('--include-received', action='store_true',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
|
@ -480,7 +480,8 @@ class ZfsAutobackup(ZfsAuto):
|
||||
( source_datasets, excluded_datasets) = source_node.selected_datasets(property_name=self.property_name,
|
||||
exclude_received=self.args.exclude_received,
|
||||
exclude_paths=self.exclude_paths,
|
||||
exclude_unchanged=self.args.exclude_unchanged)
|
||||
exclude_unchanged=self.args.exclude_unchanged,
|
||||
only_received=self.args.only_received)
|
||||
if not source_datasets and not excluded_datasets:
|
||||
self.print_error_sources()
|
||||
return 255
|
||||
|
@ -243,7 +243,8 @@ class ZfsAutoverify(ZfsAuto):
|
||||
( source_datasets, excluded_datasets) = source_node.selected_datasets(property_name=self.property_name,
|
||||
exclude_received=self.args.exclude_received,
|
||||
exclude_paths=self.exclude_paths,
|
||||
exclude_unchanged=self.args.exclude_unchanged)
|
||||
exclude_unchanged=self.args.exclude_unchanged,
|
||||
only_received=self.args.only_received)
|
||||
if not source_datasets and not excluded_datasets:
|
||||
self.print_error_sources()
|
||||
return 255
|
||||
|
@ -139,7 +139,7 @@ class ZfsDataset:
|
||||
|
||||
|
||||
|
||||
def is_selected(self, value, source, inherited, exclude_received, exclude_paths, exclude_unchanged):
|
||||
def is_selected(self, value, source, inherited, exclude_received, exclude_paths, exclude_unchanged, only_received=False):
|
||||
"""determine if dataset should be selected for backup (called from
|
||||
ZfsNode)
|
||||
|
||||
@ -150,6 +150,7 @@ class ZfsDataset:
|
||||
:type inherited: bool
|
||||
:type exclude_received: bool
|
||||
:type exclude_unchanged: int
|
||||
:type only_received: bool
|
||||
|
||||
:param value: Value of the zfs property ("false"/"true"/"child"/parent/"-")
|
||||
:param source: Source of the zfs property ("local"/"received", "-")
|
||||
@ -203,6 +204,14 @@ class ZfsDataset:
|
||||
self.verbose("Excluded (dataset already received)")
|
||||
return False
|
||||
|
||||
if only_received:
|
||||
self.verbose("Selected (by --only-received)")
|
||||
return True
|
||||
|
||||
elif only_received:
|
||||
self.verbose("Excluded (by --only-received)")
|
||||
return False
|
||||
|
||||
if not self.is_changed(exclude_unchanged):
|
||||
self.verbose("Excluded (by --exclude-unchanged)")
|
||||
return False
|
||||
|
@ -239,7 +239,7 @@ class ZfsNode(ExecuteNode):
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
def selected_datasets(self, property_name, exclude_received, exclude_paths, exclude_unchanged):
|
||||
def selected_datasets(self, property_name, exclude_received, exclude_paths, exclude_unchanged, only_received):
|
||||
"""determine filesystems that should be backed up by looking at the special autobackup-property, systemwide
|
||||
|
||||
returns: ( list of selected ZfsDataset, list of excluded ZfsDataset)
|
||||
@ -277,7 +277,7 @@ class ZfsNode(ExecuteNode):
|
||||
|
||||
# determine it
|
||||
selected=dataset.is_selected(value=value, source=source, inherited=inherited, exclude_received=exclude_received,
|
||||
exclude_paths=exclude_paths, exclude_unchanged=exclude_unchanged)
|
||||
exclude_paths=exclude_paths, exclude_unchanged=exclude_unchanged, only_received=only_received)
|
||||
|
||||
if selected==True:
|
||||
selected_filesystems.append(dataset)
|
||||
|
Loading…
x
Reference in New Issue
Block a user