Fabien BOURGEOIS
cf48101dfb
* Do not use envsubst anymore but python os.environ ; * Options for config : PLAN, SOURCE and DEST, EXCLUDE_WORDS ; * Add synchronization with rsync+SSH with REMOTE env variables.
19 lines
675 B
Python
19 lines
675 B
Python
from os import environ
|
|
from subprocess import Popen
|
|
from shlex import split as shplit
|
|
|
|
# Remote syncing, when needed
|
|
|
|
def sync():
|
|
""" Remote syncing """
|
|
DEST = environ.get('DEST')
|
|
REMOTE_HOST = environ.get('REMOTE_HOST', False)
|
|
if REMOTE_HOST:
|
|
REMOTE_USER = environ.get('REMOTE_USER')
|
|
REMOTE_PASS = environ.get('REMOTE_PASS')
|
|
print('Remote host %s configured : will sync with it' % REMOTE_HOST)
|
|
command = ('sshpass -p %s rsync -av --delete -e '
|
|
'"ssh -p 23 -o StrictHostKeyChecking=no" '
|
|
'%s %s@%s:./backups') % (REMOTE_PASS, DEST, REMOTE_USER, REMOTE_HOST)
|
|
Popen(shplit(command))
|