Browse Source

requirements, obey config file rsync port

master
dave 2 years ago
parent
commit
6753fd250f
4 changed files with 18 additions and 11 deletions
  1. +1
    -1
      datadb/__init__.py
  2. +5
    -3
      datadb/datadb.py
  3. +5
    -5
      example.ini
  4. +7
    -2
      setup.py

+ 1
- 1
datadb/__init__.py View File

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

+ 5
- 3
datadb/datadb.py 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'
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()


+ 5
- 5
example.ini View File

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


+ 7
- 2
setup.py View File

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

Loading…
Cancel
Save