Skip to content

Commit

Permalink
no longer use zfs send --compressed as default. uses --zfs-compressed…
Browse files Browse the repository at this point in the history
… to reenable it. fixes #77 .
  • Loading branch information
psy0rz committed May 31, 2021
1 parent a2f3aee commit 37f91e1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/test_zfsautobackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ def test_progress(self):
n=ZfsNode("test",l)
d=ZfsDataset(n,"test_source1@test")

sp=d.send_pipe([], prev_snapshot=None, resume_token=None, show_progress=True, raw=False, send_pipes=[], send_properties=True, write_embedded=True)
sp=d.send_pipe([], prev_snapshot=None, resume_token=None, show_progress=True, raw=False, send_pipes=[], send_properties=True, write_embedded=True, zfs_compressed=True)


with OutputIO() as buf:
Expand Down
8 changes: 7 additions & 1 deletion zfs_autobackup/ZfsAutobackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def __init__(self, argv, print_arguments=True):
parser.add_argument('--encrypt', action='store_true',
help='Encrypt data after receiving it.')

parser.add_argument('--zfs-compressed', action='store_true',
help='Transfer blocks that already have zfs-compression as-is.')

parser.add_argument('--test', action='store_true',
help='dont change anything, just show what would be done (still does all read-only '
'operations)')
Expand Down Expand Up @@ -166,6 +169,9 @@ def __init__(self, argv, print_arguments=True):
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-compress, might be inefficient.")

def verbose(self, txt):
self.log.verbose(txt)

Expand Down Expand Up @@ -381,7 +387,7 @@ def sync_datasets(self, source_node, source_datasets, target_node):
no_send=self.args.no_send,
destroy_incompatible=self.args.destroy_incompatible,
send_pipes=send_pipes, recv_pipes=recv_pipes,
decrypt=self.args.decrypt, encrypt=self.args.encrypt, )
decrypt=self.args.decrypt, encrypt=self.args.encrypt, zfs_compressed=self.args.zfs_compressed )
except Exception as e:
fail_count = fail_count + 1
source_dataset.error("FAILED: " + str(e))
Expand Down
12 changes: 6 additions & 6 deletions zfs_autobackup/ZfsDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def datasets(self, types="filesystem,volume"):

return self.from_names(names[1:])

def send_pipe(self, features, prev_snapshot, resume_token, show_progress, raw, send_properties, write_embedded, send_pipes):
def send_pipe(self, features, prev_snapshot, resume_token, show_progress, raw, send_properties, write_embedded, send_pipes, zfs_compressed):
"""returns a pipe with zfs send output for this snapshot
resume_token: resume sending from this token. (in that case we don't
Expand All @@ -530,7 +530,7 @@ def send_pipe(self, features, prev_snapshot, resume_token, show_progress, raw, s
if write_embedded and 'embedded_data' in features and "-e" in self.zfs_node.supported_send_options:
cmd.append("--embed") # WRITE_EMBEDDED, more compact stream

if "-c" in self.zfs_node.supported_send_options:
if zfs_compressed and "-c" in self.zfs_node.supported_send_options:
cmd.append("--compressed") # use compressed WRITE records

# raw? (send over encrypted data in its original encrypted form without decrypting)
Expand Down Expand Up @@ -634,7 +634,7 @@ def recv_pipe(self, pipe, features, recv_pipes, filter_properties=None, set_prop

def transfer_snapshot(self, target_snapshot, features, prev_snapshot, show_progress,
filter_properties, set_properties, ignore_recv_exit_code, resume_token,
raw, send_properties, write_embedded, send_pipes, recv_pipes):
raw, send_properties, write_embedded, send_pipes, recv_pipes, zfs_compressed):
"""transfer this snapshot to target_snapshot. specify prev_snapshot for
incremental transfer
Expand Down Expand Up @@ -673,7 +673,7 @@ def transfer_snapshot(self, target_snapshot, features, prev_snapshot, show_progr

# do it
pipe = self.send_pipe(features=features, show_progress=show_progress, prev_snapshot=prev_snapshot,
resume_token=resume_token, raw=raw, send_properties=send_properties, write_embedded=write_embedded, send_pipes=send_pipes)
resume_token=resume_token, raw=raw, send_properties=send_properties, write_embedded=write_embedded, send_pipes=send_pipes, zfs_compressed=zfs_compressed)
target_snapshot.recv_pipe(pipe, features=features, filter_properties=filter_properties,
set_properties=set_properties, ignore_exit_code=ignore_recv_exit_code, recv_pipes=recv_pipes)

Expand Down Expand Up @@ -968,7 +968,7 @@ def handle_incompatible_snapshots(self, incompatible_target_snapshots, destroy_i

def sync_snapshots(self, target_dataset, features, show_progress, filter_properties, set_properties,
ignore_recv_exit_code, holds, rollback, decrypt, encrypt, also_other_snapshots,
no_send, destroy_incompatible, send_pipes, recv_pipes):
no_send, destroy_incompatible, send_pipes, recv_pipes, zfs_compressed):
"""sync this dataset's snapshots to target_dataset, while also thinning
out old snapshots along the way.
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def sync_snapshots(self, target_dataset, features, show_progress, filter_propert
filter_properties=active_filter_properties,
set_properties=active_set_properties,
ignore_recv_exit_code=ignore_recv_exit_code,
resume_token=resume_token, write_embedded=write_embedded, raw=raw, send_properties=send_properties, send_pipes=send_pipes, recv_pipes=recv_pipes)
resume_token=resume_token, write_embedded=write_embedded, raw=raw, send_properties=send_properties, send_pipes=send_pipes, recv_pipes=recv_pipes, zfs_compressed=zfs_compressed)

resume_token = None

Expand Down

0 comments on commit 37f91e1

Please sign in to comment.