Skip to content

Commit

Permalink
Merge pull request #63 from ddebeau/fix/snapshot-size
Browse files Browse the repository at this point in the history
Use raw option when determining snapshot size
  • Loading branch information
ddebeau authored Mar 27, 2022
2 parents d8af96e + 54a6da0 commit a024abb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Fix bug where the snapshot size was incorrect due to the command missing the
raw mode argument.
[#60](https://github.com/ddebeau/zfs_uploader/issues/60)

## [0.7.2](https://github.com/ddebeau/zfs_uploader/compare/0.7.1...0.7.2) 2022-02-09

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions zfs_uploader/zfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ def destroy_filesystem(filesystem):


def get_snapshot_send_size(filesystem, snapshot_name):
cmd = ['zfs', 'send', '--parsable', '--dryrun',
cmd = ['zfs', 'send', '--raw', '--parsable', '--dryrun',
f'{filesystem}@{snapshot_name}']
out = subprocess.run(cmd, **SUBPROCESS_KWARGS)
return out.stdout.splitlines()[1].split()[1]


def get_snapshot_send_size_inc(filesystem, snapshot_name_1, snapshot_name_2):
cmd = ['zfs', 'send', '--parsable', '--dryrun', '-i',
cmd = ['zfs', 'send', '--raw', '--parsable', '--dryrun', '-i',
f'{filesystem}@{snapshot_name_1}',
f'{filesystem}@{snapshot_name_2}']
out = subprocess.run(cmd, **SUBPROCESS_KWARGS)
Expand All @@ -70,7 +70,7 @@ def get_snapshot_send_size_inc(filesystem, snapshot_name_1, snapshot_name_2):
def open_snapshot_stream(filesystem, snapshot_name, mode):
""" Open snapshot stream. """
if mode == 'r':
cmd = ['zfs', 'send', '-w', f'{filesystem}@{snapshot_name}']
cmd = ['zfs', 'send', '--raw', f'{filesystem}@{snapshot_name}']
return subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
elif mode == 'w':
Expand All @@ -84,7 +84,7 @@ def open_snapshot_stream(filesystem, snapshot_name, mode):

def open_snapshot_stream_inc(filesystem, snapshot_name_1, snapshot_name_2):
""" Open incremental snapshot read stream. """
cmd = ['zfs', 'send', '-w', '-i', f'{filesystem}@{snapshot_name_1}',
cmd = ['zfs', 'send', '--raw', '-i', f'{filesystem}@{snapshot_name_1}',
f'{filesystem}@{snapshot_name_2}']
return subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

0 comments on commit a024abb

Please sign in to comment.