diff --git a/README.rst b/README.rst index d30a4f7..b562f23 100644 --- a/README.rst +++ b/README.rst @@ -187,6 +187,7 @@ The backup process consists of several steps: ``--disable-notifications``,"By default a desktop notification is shown (using notify-send) before the system backup starts and after the backup finishes. The use of this option disables the notifications (notify-send will not be called at all)." + "``--rsync-option``, "Pass additional rsync option directly to rsync." "``-v``, ``--verbose``",Make more noise (increase logging verbosity). Can be repeated. "``-q``, ``--quiet``",Make less noise (decrease logging verbosity). Can be repeated. "``-h``, ``--help``",Show this message and exit. diff --git a/rsync_system_backup/__init__.py b/rsync_system_backup/__init__.py index 963db2c..64a5f5f 100644 --- a/rsync_system_backup/__init__.py +++ b/rsync_system_backup/__init__.py @@ -201,6 +201,13 @@ def exclude_list(self): """ return [] + @lazy_property(writable=True) + def rsync_option(self): + """Pass an option directly to rsync (a string or :data:`None`).""" + return [] + #return value + #return self.rsync_option + @lazy_property(writable=True) def excluded_roots(self): """ @@ -539,6 +546,9 @@ def transfer_changes(self): rsync_command.append('--hard-links') rsync_command.append('--numeric-ids') rsync_command.append('--xattrs') + # Append additional rsync option + for pattern in self.rsync_option: + rsync_command.append('%s' % pattern) # The following rsync option avoids including mounted external # drives like USB sticks in system backups. if not self.multi_fs: diff --git a/rsync_system_backup/cli.py b/rsync_system_backup/cli.py index 8ad3b11..077fca5 100644 --- a/rsync_system_backup/cli.py +++ b/rsync_system_backup/cli.py @@ -150,6 +150,10 @@ system backup starts and after the backup finishes. The use of this option disables the notifications (notify-send will not be called at all). + --rsync-option + + Pass down additional options directly to rsync. + -v, --verbose Make more noise (increase logging verbosity). Can be repeated. @@ -203,7 +207,7 @@ def main(): try: options, arguments = getopt.gnu_getopt(sys.argv[1:], 'bsrm:c:t:i:unx:fvqh', [ 'backup', 'snapshot', 'rotate', 'mount=', 'crypto=', 'tunnel=', - 'ionice=', 'no-sudo', 'dry-run', 'multi-fs', 'exclude=', 'force', + 'ionice=', 'no-sudo', 'dry-run', 'multi-fs', 'rsync-option=', 'exclude=', 'force', 'disable-notifications', 'verbose', 'quiet', 'help', ]) for option, value in options: @@ -246,6 +250,9 @@ def main(): program_opts['exclude_list'].append(value) elif option == '--multi-fs': program_opts['multi_fs'] = True + elif option == '--rsync-option': + program_opts.setdefault('rsync_option', []) + program_opts['rsync_option'].append(value) elif option == '--disable-notifications': program_opts['notifications_enabled'] = False elif option in ('-v', '--verbose'):