[IMP]RsyncVolumes : add SYNC_EXTRA_PATHES if needed
Managing multiple extra paths to sync (source and dest folder)
This commit is contained in:
parent
9529806dea
commit
570c5e7f9e
@ -12,7 +12,18 @@ def sync():
|
|||||||
REMOTE_USER = environ.get('REMOTE_USER')
|
REMOTE_USER = environ.get('REMOTE_USER')
|
||||||
REMOTE_PASS = environ.get('REMOTE_PASS')
|
REMOTE_PASS = environ.get('REMOTE_PASS')
|
||||||
print('Remote host %s configured : will sync with it' % REMOTE_HOST)
|
print('Remote host %s configured : will sync with it' % REMOTE_HOST)
|
||||||
command = ('sshpass -p %s rsync -av --delete -e '
|
paths = [DEST]
|
||||||
'"ssh -p 23 -o StrictHostKeyChecking=no" '
|
SYNC_EXTRA_PATHES = environ.get('SYNC_EXTRA_PATHES', False)
|
||||||
'%s %s@%s:./backups') % (REMOTE_PASS, DEST, REMOTE_USER, REMOTE_HOST)
|
if SYNC_EXTRA_PATHES:
|
||||||
Popen(shplit(command))
|
paths += SYNC_EXTRA_PATHES.split(',')
|
||||||
|
def run(path):
|
||||||
|
print('Syncing %s...' % path)
|
||||||
|
_paths = path.split(':')
|
||||||
|
lpath = _paths[0]
|
||||||
|
rpath = _paths[1] if len(_paths) > 1 else 'backups'
|
||||||
|
command = ('sshpass -p %s rsync -av --delete -e '
|
||||||
|
'"ssh -p 23 -o StrictHostKeyChecking=no" '
|
||||||
|
'%s %s@%s:./%s') % (REMOTE_PASS, lpath, REMOTE_USER, REMOTE_HOST, rpath)
|
||||||
|
p = Popen(shplit(command))
|
||||||
|
p.communicate()
|
||||||
|
map(run, paths)
|
||||||
|
Loading…
Reference in New Issue
Block a user