bundles/backup-server: improve

This commit is contained in:
Franzi 2025-04-16 09:02:18 +02:00
parent c905b7dc13
commit a15740c899
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 22 additions and 46 deletions

View file

@ -15,16 +15,15 @@ for line in check_output('LC_ALL=C zfs list -H -t snapshot -o name', shell=True)
line = line.decode('UTF-8')
if line.startswith('{}/'.format(server_settings['zfs-base'])):
dataset, snapname = line.split('@', 1)
try:
dataset, snapname = line.split('@', 1)
dataset = dataset.split('/')[-1]
ts, bucket = snapname.split('-', 1)
dataset = dataset.split('/')[-1]
ts, bucket = snapname.split('-', 1)
if not ts.isdigit():
# garbage, ignore
continue
snapshots[dataset].add(int(ts))
snapshots[dataset].add(int(ts))
except Exception as e:
print(f"Exception while parsing snapshot name {line!r}: {e!r}")
backups = {}
for dataset, snaps in snapshots.items():