ignore "snaphost already exists"-errors when creating snapshots
This commit is contained in:
parent
3cbeaa887f
commit
89a19edd6d
@ -6,6 +6,7 @@ import sys
|
|||||||
|
|
||||||
time_format='%Y-%m-%d_%H%M'
|
time_format='%Y-%m-%d_%H%M'
|
||||||
re_snapshot = re.compile(r'^(.*)@([0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{4})$')
|
re_snapshot = re.compile(r'^(.*)@([0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{4})$')
|
||||||
|
re_err_ok = re.compile(r"cannot create snapshot '[^']+': dataset already exists")
|
||||||
logger = 'zsnapper'
|
logger = 'zsnapper'
|
||||||
|
|
||||||
class ZFSSnapshotError(Exception):
|
class ZFSSnapshotError(Exception):
|
||||||
@ -33,7 +34,12 @@ def do_zfs_command(args, zfs_cmd, pipecmd=None):
|
|||||||
|
|
||||||
(out, err) = ctrl_proc.communicate()
|
(out, err) = ctrl_proc.communicate()
|
||||||
|
|
||||||
if ctrl_proc.returncode != 0:
|
# check if we try to create a snapshot that already exists. This can happen
|
||||||
|
# if the script is run every minute and it takes more time than that to
|
||||||
|
# create all snapshots
|
||||||
|
if ctrl_proc.returncode == 1 && re_match(re_err_ok, err):
|
||||||
|
pass
|
||||||
|
elif ctrl_proc.returncode != 0:
|
||||||
raise ZFSSnapshotError('Failed to execute {}: {}'.format(cmd, err))
|
raise ZFSSnapshotError('Failed to execute {}: {}'.format(cmd, err))
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user