Skip to content

Instantly share code, notes, and snippets.

@cclloyd
Created January 24, 2020 06:06
Show Gist options
  • Save cclloyd/8b53b8055cf31a084860188591978c30 to your computer and use it in GitHub Desktop.
Save cclloyd/8b53b8055cf31a084860188591978c30 to your computer and use it in GitHub Desktop.
Ceph librbd export-diff non-working example
'''
Issues:
- Size of written file not identical to size crated by `rbd export-diff` command.
- Total size of extents does not equal diff-size
'''
offsets = []
extents = []
def iter_cb(offset, length, exists):
if exists:
offsets.append(offset)
extents.append(length)
image.diff_iterate(0, image.size(), None, iter_cb)
with open(os.path.join(BACKUP_DIR, 'test.img'), 'wb') as f:
for offset, extent in zip(offsets, extents):
f.write(image.read(offset, extent))
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment