Browse Source

updated snapshot name extraction

master
Holger Frey 5 years ago
parent
commit
eca161b33a
  1. 17
      zfs-snapshot-backup.py

17
zfs-snapshot-backup.py

@ -68,10 +68,19 @@ def gzip_filename(current, last=None):
def extract_snapshot_name(filename): def extract_snapshot_name(filename):
parts = filename.split(".") # elabfs-LukasMetzler@auto-20190807.0200-1w.gz
if len(parts) in (2, 4): if not filename.endswith(".gz"):
# snapshot1.gz or snapshot1.to.snapshot2.gz raise ValueError(f"Not a gzip file: {filename}")
return parts[-2] if not filename.startswith(ZFS_ELAB_PREFIX):
raise ValueError(f"Not an elabfs snapshot: {filename}")
snapshot = filename[:-3]
if snapshot.count(".") == 1 and snapshot.count("@") == 1:
# elabfs-...@auto-20190807.0200-1w
return snapshot
elif snapshot.count(".to.") == 1 and snapshot.count("@") == 2:
# elabfs-...@auto-20190806.0200-1w.to.elabfs-...@auto-20190807.0200-1w
old_snapshot, new_snapshot = snapshot.split(".to.")
return new_snapshot
else: else:
raise ValueError(f"Unknown Filename Format: {filename}") raise ValueError(f"Unknown Filename Format: {filename}")

Loading…
Cancel
Save