From 478de022cf01fba14af28ae014d5dc4991fffabb Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Thu, 14 Jan 2021 04:58:45 +0100 Subject: [PATCH 1/2] remote sync command only if no user is given. --- .gitignore | 3 +++ example/sync_config.py | 11 +++++------ mysync | 5 ++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index e61bca2..3f8aedb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +config.py +*~ + # ---> Python # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/example/sync_config.py b/example/sync_config.py index c3b562e..2e83f10 100644 --- a/example/sync_config.py +++ b/example/sync_config.py @@ -4,11 +4,9 @@ import sys backup = False hosts = ['ahorn', 'erle', 'linde'] -__basepath__ = '/user_data' +__basepath__ = '/usr/data' entries = ( - ('dirk@%s:/user_data/bin', os.path.join(__basepath__, 'bin'), None), - ('dirk@%s:/user_data/data', os.path.join(__basepath__, 'data'), None), - ('dirk@%s:/user_data/static_data', os.path.join(__basepath__, 'static_data'), ['Audio', 'timeshift', 'lost+found']), + ('dirk@%s:/usr/data', __basepath__, None), ('dirk@%s:/home', '/home', None), ) @@ -21,5 +19,6 @@ for host in hosts: setattr(sys.modules[__name__], host + '_' + os.path.basename(local) + '_skip', skip) -mount_mockery_audio_remotepath = 'root@mount-mockery.de:/data/audio/items' -mount_mockery_audio_localpath = os.path.join(__basepath__, 'static_data', 'dirk', 'Audio') +mount_mockery_audio_remotepath = 'root@mount-mockery.de:/data/audio' +mount_mockery_audio_localpath = os.path.join(__basepath__, 'dirk', 'Audio') + diff --git a/mysync b/mysync index d7cb6f9..0840c0f 100755 --- a/mysync +++ b/mysync @@ -68,7 +68,10 @@ def rsync_command(**kwargs): if localpath is not None: remotepath = path_filter(kwargs.get(PROP_REMOTE)) skip = kwargs.get(PROP_SKIP) - cmd_l = ['rsync', '-avn' if DEBUG else '-av', '--delete', '--rsync-path="%s"' % RSYNC_REMOTE_COMMAND, remotepath, localpath] + if remotepath.find('@') != -1: + cmd_l = ['rsync', '-avn' if DEBUG else '-av', '--delete', remotepath, localpath] + else: + cmd_l = ['rsync', '-avn' if DEBUG else '-av', '--delete', '--rsync-path="%s"' % RSYNC_REMOTE_COMMAND, remotepath, localpath] if skip is not None: cmd_l.append('--exclude=%s' % ','.join(skip)) if not os.path.exists(localpath): From 864bf1de99fa1238119ebfc20bceebca7dbc2a48 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Thu, 14 Jan 2021 05:10:13 +0100 Subject: [PATCH 2/2] buche added to sync example --- example/sync_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/sync_config.py b/example/sync_config.py index 2e83f10..64e1b15 100644 --- a/example/sync_config.py +++ b/example/sync_config.py @@ -3,7 +3,7 @@ import sys backup = False -hosts = ['ahorn', 'erle', 'linde'] +hosts = ['ahorn', 'buche', 'erle', 'linde'] __basepath__ = '/usr/data' entries = ( ('dirk@%s:/usr/data', __basepath__, None),