From fa3328b1666cb11d2047f629d8ed0ce12f1baceb Mon Sep 17 00:00:00 2001 From: Maarten Dijkema Date: Fri, 21 Aug 2020 13:01:26 +0200 Subject: [PATCH 1/3] Add --rsync_option to command line options. Now it is possible to pass down additional options directly to rsync. rsync_system_backup tries to preserve as much as possible and to do so, enables --acls by default. This breaks using FreeNAS as a destination. Now it is possible to use --rsync_option='--no-A' --- rsync_system_backup/__init__.py | 10 ++++++++++ rsync_system_backup/cli.py | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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..b917897 100644 --- a/rsync_system_backup/cli.py +++ b/rsync_system_backup/cli.py @@ -203,7 +203,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 +246,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'): From 6e9f1c5b676e0b9a0120795d01eb29044a468385 Mon Sep 17 00:00:00 2001 From: Maarten Dijkema Date: Fri, 21 Aug 2020 13:07:58 +0200 Subject: [PATCH 2/3] Update README and help info. --- README.rst | 1 + rsync_system_backup/cli.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README.rst b/README.rst index d30a4f7..990f1fb 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/cli.py b/rsync_system_backup/cli.py index b917897..640e14c 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. From 8e0b0b965ea5655bf8d1d1c916545fcda078d86e Mon Sep 17 00:00:00 2001 From: Maarten Dijkema Date: Sat, 22 Aug 2020 11:37:33 +0200 Subject: [PATCH 3/3] Adhere to convention: changed --rsync_option to --rsync-option. --- README.rst | 2 +- rsync_system_backup/cli.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 990f1fb..b562f23 100644 --- a/README.rst +++ b/README.rst @@ -187,7 +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." + "``--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/cli.py b/rsync_system_backup/cli.py index 640e14c..077fca5 100644 --- a/rsync_system_backup/cli.py +++ b/rsync_system_backup/cli.py @@ -150,7 +150,7 @@ 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 + --rsync-option Pass down additional options directly to rsync. @@ -207,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', 'rsync_option=', 'exclude=', 'force', + 'ionice=', 'no-sudo', 'dry-run', 'multi-fs', 'rsync-option=', 'exclude=', 'force', 'disable-notifications', 'verbose', 'quiet', 'help', ]) for option, value in options: @@ -250,7 +250,7 @@ def main(): program_opts['exclude_list'].append(value) elif option == '--multi-fs': program_opts['multi_fs'] = True - elif option == '--rsync_option': + elif option == '--rsync-option': program_opts.setdefault('rsync_option', []) program_opts['rsync_option'].append(value) elif option == '--disable-notifications':