Skip to content

Commit

Permalink
FIX creating missing filesystems on dest #3
Browse files Browse the repository at this point in the history
  • Loading branch information
orgoj committed Apr 1, 2021
1 parent 5038553 commit 4e2984e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyznap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"""


__version__ = '1.6.0o15'
__version__ = '1.6.0o16'
13 changes: 11 additions & 2 deletions pyznap/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def send_snap(snapshot, dest_name, base=None, ssh_dest=None, raw=False, resume=F
return 0


def send_filesystem(source_fs, dest_name, ssh_dest=None, raw=False, resume=False, send_last_snapshot=False):
def send_filesystem(source_fs, dest_name, ssh_dest=None, raw=False, resume=False, send_last_snapshot=False, dest_auto_create=False):
"""Checks for common snapshots between source and dest.
If none are found, send the oldest snapshot, then update with the most recent one.
If there are common snaps, update destination with the most recent one.
Expand Down Expand Up @@ -148,6 +148,14 @@ def send_filesystem(source_fs, dest_name, ssh_dest=None, raw=False, resume=False
try:
dest_fs = zfs.open(dest_name, ssh=ssh_dest)
except DatasetNotFoundError:
if dest_auto_create:
logger.info('Destination {:s} does not exist, will create it...'.format(dest_name_log))
if create_dataset(dest_name, dest_name_log, ssh=ssh_dest):
return 1
else:
logger.error('Destination {:s} does not exist, manually create it or use "dest-auto-create" option...'
.format(dest_name_log))
return 1
dest_snapnames = []
common = set()
except CalledProcessError as err:
Expand Down Expand Up @@ -353,7 +361,8 @@ def send_config(config):
# TODO: create missing skipped filesystem on destination
# send not excluded filesystems
for retry in range(1,retries+2):
rc = send_filesystem(source_fs, dest_name, ssh_dest=ssh_dest, raw=raw, resume=resume, send_last_snapshot=send_last_snapshot)
rc = send_filesystem(source_fs, dest_name, ssh_dest=ssh_dest, raw=raw, resume=resume,
send_last_snapshot=send_last_snapshot, dest_auto_create=dest_auto_create)
if rc == 2 and retry <= retries:
logger.info('Retrying send in {:d}s (retry {:d} of {:d})...'.format(retry_interval, retry, retries))
sleep(retry_interval)
Expand Down

0 comments on commit 4e2984e

Please sign in to comment.