diff --git a/.gitignore b/.gitignore index e61bca2..10fc1cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,25 @@ +config.py + +# ---> Eclipse +.project +.pydevproject +.settings + +# ---> Linux +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + # ---> Python # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/example/backup_config.py b/example/backup_config.py index af5a1c9..d40c12b 100644 --- a/example/backup_config.py +++ b/example/backup_config.py @@ -2,13 +2,14 @@ import os import sys backup = True -backup_basepath = '/data/backup/ahorn' +host = 'erle' +backup_basepath = '/data/backup/data' installations = ['mint', 'kubuntu', 'openSuSE'] for installation in installations: - setattr(sys.modules[__name__], 'home_%s_remotepath' % installation, 'dirk@ahorn:/home') + setattr(sys.modules[__name__], 'home_%s_remotepath' % installation, 'dirk@%s:/home' % host) setattr(sys.modules[__name__], 'home_%s_localpath' % installation, os.path.join(installation, 'home')) -user_data_remotepath = 'dirk@ahorn:/user_data' -user_data_localpath = 'user_data' -user_data_skip = ['static_data'] +data_remotepath = 'dirk@%s:/usr/data' % host +data_localpath = 'usr/data' +data_skip = ['lost+found', 'dirk/Audio', 'dirk/bin', 'dirk/gnome-boxes', 'dirk/media_images', 'dirk/Videos'] diff --git a/example/sync_config.py b/example/sync_config.py index c3b562e..c9d5f59 100644 --- a/example/sync_config.py +++ b/example/sync_config.py @@ -4,22 +4,24 @@ 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__, ['lost+found']), + ('dirk@%s:/usr/data', __basepath__, ['lost+found', 'dirk/Audio', 'dirk/bin', 'dirk/Downloads', 'dirk/gnome-boxes', 'dirk/media_images', 'dirk/Videos']), ('dirk@%s:/home', '/home', None), ) for host in hosts: for remote, local, skip in entries: - setattr(sys.modules[__name__], host + '_' + os.path.basename(local) + '_remotepath', remote % host) - setattr(sys.modules[__name__], host + '_' + os.path.basename(local) + '_localpath', local) + name = os.path.basename(local) if skip is not None: - setattr(sys.modules[__name__], host + '_' + os.path.basename(local) + '_skip', skip) + if len(skip) > 1: + name += '_short' + setattr(sys.modules[__name__], host + '_' + name + '_skip', skip) + setattr(sys.modules[__name__], host + '_' + name + '_remotepath', remote % host) + setattr(sys.modules[__name__], host + '_' + name + '_localpath', local) -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..fa15a6f 100755 --- a/mysync +++ b/mysync @@ -10,7 +10,7 @@ import subprocess DEBUG = False -RSYNC_REMOTE_COMMAND = 'sudo rsync' +RSYNC_REMOTE_COMMAND = 'rsync' TIME_FORMAT = "%Y-%m-%d_%H-%M-%S" try: basepath = config.backup_basepath @@ -70,7 +70,10 @@ def rsync_command(**kwargs): skip = kwargs.get(PROP_SKIP) 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)) + for skip_dir in skip: + if not skip_dir.endswith('/'): + skip_dir += '/' + cmd_l.append('--exclude=%s' % skip_dir) if not os.path.exists(localpath): return 'mkdir -p %s && ' % localpath + ' '.join(cmd_l) return ' '.join(cmd_l)