fix: atomic snapshots can only be created per pool. now uses a seperate zfs snapshot command for each pool

This commit is contained in:
Edwin Eefting 2018-03-06 15:54:00 +01:00
parent cc45122e3e
commit b0ffdb4893

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python2
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
@ -165,23 +165,32 @@ test_snapshots={}
"""create snapshot on multiple filesystems at once (atomicly)""" """create snapshot on multiple filesystems at once (atomicly per pool)"""
def zfs_create_snapshot(ssh_to, filesystems, snapshot): def zfs_create_snapshot(ssh_to, filesystems, snapshot):
cmd=[ "zfs", "snapshot" ]
#collect per pool, zfs can only take atomic snapshots per pool
pools={}
for filesystem in filesystems: for filesystem in filesystems:
cmd.append(filesystem+"@"+snapshot) pool=filesystem.split('/')[0]
if pool not in pools:
pools[pool]=[]
pools[pool].append(filesystem)
#in testmode we dont actually make changes, so keep them in a list to simulate for pool in pools:
if args.test: cmd=[ "zfs", "snapshot" ]
if not ssh_to in test_snapshots: for filesystem in pools[pool]:
test_snapshots[ssh_to]={} cmd.append(filesystem+"@"+snapshot)
if not filesystem in test_snapshots[ssh_to]:
test_snapshots[ssh_to][filesystem]=[]
test_snapshots[ssh_to][filesystem].append(snapshot)
run(ssh_to=ssh_to, tab_split=False, cmd=cmd, test=args.test) #in testmode we dont actually make changes, so keep them in a list to simulate
if args.test:
if not ssh_to in test_snapshots:
test_snapshots[ssh_to]={}
if not filesystem in test_snapshots[ssh_to]:
test_snapshots[ssh_to][filesystem]=[]
test_snapshots[ssh_to][filesystem].append(snapshot)
run(ssh_to=ssh_to, tab_split=False, cmd=cmd, test=args.test)
"""get names of all snapshots for specified filesystems belonging to backup_name """get names of all snapshots for specified filesystems belonging to backup_name