requirements, obey config file rsync port

This commit is contained in:
dave 2018-10-07 16:21:49 -07:00
parent e60e32f688
commit 6753fd250f
4 changed files with 18 additions and 11 deletions

View File

@ -1 +1 @@
__version__ = "0.0.9" __version__ = "0.0.10"

View File

@ -12,8 +12,7 @@ from threading import Thread
SSH_KEY_PATH = environ["DATADB_KEYPATH"] if "DATADB_KEYPATH" in environ else '/root/.ssh/datadb.key' 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', RSYNC_DEFAULT_ARGS = ['rsync', '-avzr', '--exclude=.datadb.lock', '--whole-file', '--one-file-system', '--delete']
'ssh -i {} -p 4874 -o StrictHostKeyChecking=no'.format(SSH_KEY_PATH)]
DATADB_HTTP_API = environ.get('DATADB_HTTP_API', 'http://datadb.services.davepedu.com:4875/cgi-bin/') 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': if dest.scheme == 'rsync':
args = RSYNC_DEFAULT_ARGS[:] 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 # Excluded paths
if conf["exclude"]: 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() rsync_path, token = get(DATADB_HTTP_API + 'new_backup', params=new_backup_params).json()
# Add rsync source path # 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))) # 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)) upload = put(put_url, data=WrappedStdout(tar.stdout))
if upload.status_code != 200: if upload.status_code != 200:
print(upload.text)
raise Exception("Upload failed with code: {}".format(upload.status_code)) raise Exception("Upload failed with code: {}".format(upload.status_code))
tar.wait() tar.wait()

View File

@ -1,6 +1,6 @@
[testing_rsync] [testing_rsync]
uri=rsync://datadb.services.davepedu.com/testing_rsync uri=rsync://127.0.0.1:8022/testing_rsync
dir=/Users/dave/Downloads/rtest/src dir=/home/dave/code/my/datadb-cli/test/s2
keep=1 keep=1
auth= auth=
restore_preexec= restore_preexec=
@ -10,9 +10,9 @@ export_postexec=
exclude=c,d exclude=c,d
[testing_archive] [testing_archive]
uri=archive://datadb.services.davepedu.com/testing_archive uri=archive://datadbxx.services.davepedu.com/testing_archive
dir=/Users/dave/Downloads/rtest/src dir=/home/dave/code/my/datadb-cli/test/s1
keep=1 keep=5
auth= auth=
restore_preexec= restore_preexec=
restore_postexec= restore_postexec=

View File

@ -1,8 +1,12 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from setuptools import setup from setuptools import setup
import os
from datadb import __version__ from datadb import __version__
with open(os.path.join(os.path.dirname(__file__), 'requirements.txt')) as f:
requirements = f.read().splitlines()
setup(name='datadb', setup(name='datadb',
version=__version__, version=__version__,
description='datadb cli module', description='datadb cli module',
@ -10,4 +14,5 @@ setup(name='datadb',
author='dpedu', author='dpedu',
author_email='dave@davepedu.com', author_email='dave@davepedu.com',
packages=['datadb'], packages=['datadb'],
scripts=['bin/datadb']) scripts=['bin/datadb'],
install_requires=requirements)