3 Commits

Author SHA1 Message Date
3d6997b3be bumped version 2020-12-21 16:08:11 +01:00
ac712da881 fix syntax 2020-12-20 08:20:52 +01:00
89a19edd6d ignore "snaphost already exists"-errors when creating snapshots 2020-12-20 08:13:09 +01:00
2 changed files with 8 additions and 2 deletions

View File

@ -6,7 +6,7 @@ try:
except ImportError: except ImportError:
from distutils import setup from distutils import setup
version = '0.3' version = '0.3.1'
setup( setup(
name='zsnapper', name='zsnapper',

View File

@ -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 and 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