From 75282597eeae5235368db5a6ab575c021084c216 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 2 Jul 2016 18:35:35 -0700 Subject: [PATCH] Confirm rsync completions --- .gitignore | 5 +++-- datadb/__init__.py | 2 +- datadb/datadb.py | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f4f5714..dd0425c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ -testenv +datadb/__init__.py andtestenv build datadb.egg-info dist test.ini datadb.key *__pycache__* - +.DS_Store +testdata diff --git a/datadb/__init__.py b/datadb/__init__.py index 27fdca4..81f0fde 100755 --- a/datadb/__init__.py +++ b/datadb/__init__.py @@ -1 +1 @@ -__version__ = "0.0.3" +__version__ = "0.0.4" diff --git a/datadb/datadb.py b/datadb/datadb.py index 7d2ffef..cdf3df1 100755 --- a/datadb/datadb.py +++ b/datadb/datadb.py @@ -8,6 +8,7 @@ from os import chmod, chown, stat, environ from enum import Enum import subprocess from requests import get,put,head +import json SSH_KEY_PATH = environ["DATADB_KEYPATH"] if "DATADB_KEYPATH" in environ else '/root/.ssh/datadb.key' RSYNC_DEFAULT_ARGS = ['rsync', '-avzr', '--exclude=.datadb.lock', '--whole-file', '--one-file-system', '--delete', '-e', 'ssh -i {} -p 4874 -o StrictHostKeyChecking=no'.format(SSH_KEY_PATH)] @@ -103,7 +104,7 @@ def backup(profile, conf, force=False): args.append(normpath(conf["dir"])+'/') # Hit backupdb via http to retreive absolute path of rsync destination of remote server - rsync_path = get(DATADB_HTTP_API+'new_backup', params={'proto':'rsync', 'name':profile, 'keep':conf["keep"]}).text.rstrip() + rsync_path, token = get(DATADB_HTTP_API+'new_backup', params={'proto':'rsync', 'name':profile, 'keep':conf["keep"]}).json() # Add rsync source path args.append(normpath('nexus@{}:{}'.format(dest.netloc, rsync_path))+'/') @@ -115,6 +116,8 @@ def backup(profile, conf, force=False): except subprocess.CalledProcessError as cpe: if cpe.returncode not in [0,24]: # ignore partial transfer due to vanishing files on our end raise + # confirm completion + put(DATADB_HTTP_API+'new_backup', params={'proto':'rsync', 'name':profile, 'token': token, 'keep':conf["keep"]}) elif dest.scheme == 'archive': # CD to local source dir