From 6753fd250feaed73b6c35061b1d74521803ebda0 Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 7 Oct 2018 16:21:49 -0700 Subject: [PATCH] requirements, obey config file rsync port --- datadb/__init__.py | 2 +- datadb/datadb.py | 8 +++++--- example.ini | 10 +++++----- setup.py | 9 +++++++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/datadb/__init__.py b/datadb/__init__.py index 00ec2dc..9b36b86 100755 --- a/datadb/__init__.py +++ b/datadb/__init__.py @@ -1 +1 @@ -__version__ = "0.0.9" +__version__ = "0.0.10" diff --git a/datadb/datadb.py b/datadb/datadb.py index dd72e70..692635f 100755 --- a/datadb/datadb.py +++ b/datadb/datadb.py @@ -12,8 +12,7 @@ from threading import Thread 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)] +RSYNC_DEFAULT_ARGS = ['rsync', '-avzr', '--exclude=.datadb.lock', '--whole-file', '--one-file-system', '--delete'] DATADB_HTTP_API = environ.get('DATADB_HTTP_API', 'http://datadb.services.davepedu.com:4875/cgi-bin/') @@ -123,6 +122,8 @@ def backup(profile, conf, force=False): if dest.scheme == 'rsync': args = RSYNC_DEFAULT_ARGS[:] + args += ['-e', 'ssh -i {} -p {} -o StrictHostKeyChecking=no'.format(SSH_KEY_PATH, dest.port or 22)] + # args += ["--port", str(dest.port or 22)] # Excluded paths if conf["exclude"]: @@ -143,7 +144,7 @@ def backup(profile, conf, force=False): rsync_path, token = get(DATADB_HTTP_API + 'new_backup', params=new_backup_params).json() # Add rsync source path - args.append(normpath('nexus@{}:{}'.format(dest.netloc, rsync_path)) + '/') + args.append(normpath('nexus@{}:{}'.format(dest.hostname, rsync_path)) + '/') # print("Rsync backup call: {}".format(' '.join(args))) @@ -198,6 +199,7 @@ def backup(profile, conf, force=False): upload = put(put_url, data=WrappedStdout(tar.stdout)) if upload.status_code != 200: + print(upload.text) raise Exception("Upload failed with code: {}".format(upload.status_code)) tar.wait() diff --git a/example.ini b/example.ini index a484d9f..7d9ad55 100644 --- a/example.ini +++ b/example.ini @@ -1,6 +1,6 @@ [testing_rsync] -uri=rsync://datadb.services.davepedu.com/testing_rsync -dir=/Users/dave/Downloads/rtest/src +uri=rsync://127.0.0.1:8022/testing_rsync +dir=/home/dave/code/my/datadb-cli/test/s2 keep=1 auth= restore_preexec= @@ -10,9 +10,9 @@ export_postexec= exclude=c,d [testing_archive] -uri=archive://datadb.services.davepedu.com/testing_archive -dir=/Users/dave/Downloads/rtest/src -keep=1 +uri=archive://datadbxx.services.davepedu.com/testing_archive +dir=/home/dave/code/my/datadb-cli/test/s1 +keep=5 auth= restore_preexec= restore_postexec= diff --git a/setup.py b/setup.py index 0df27a5..8a166ac 100755 --- a/setup.py +++ b/setup.py @@ -1,8 +1,12 @@ #!/usr/bin/env python3 from setuptools import setup - +import os from datadb import __version__ +with open(os.path.join(os.path.dirname(__file__), 'requirements.txt')) as f: + requirements = f.read().splitlines() + + setup(name='datadb', version=__version__, description='datadb cli module', @@ -10,4 +14,5 @@ setup(name='datadb', author='dpedu', author_email='dave@davepedu.com', packages=['datadb'], - scripts=['bin/datadb']) + scripts=['bin/datadb'], + install_requires=requirements)