From 518df84932da0d6dc1518e25fd28f899ca2ed14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fre=CC=81de=CC=81ric=20Calvez?= Date: Tue, 31 Jul 2018 20:09:36 +0200 Subject: [PATCH 1/2] Add option "--multi-fs" This allows rsync to cross filesystem boundaries, which is useful for my fancy partitioning scheme :) --- rsync_system_backup/__init__.py | 12 +++++++----- rsync_system_backup/cli.py | 9 ++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/rsync_system_backup/__init__.py b/rsync_system_backup/__init__.py index dfdfe90..347953c 100644 --- a/rsync_system_backup/__init__.py +++ b/rsync_system_backup/__init__.py @@ -178,6 +178,11 @@ def dry_run(self): """:data:`True` to simulate the backup without writing any files, :data:`False` otherwise.""" return False + @mutable_property + def multi_fs(self): + """:data:`True` to allow rsync to cross filesystem boundaries, :data:`False` otherwise.""" + return False + @lazy_property(writable=True) def exclude_list(self): """ @@ -528,11 +533,8 @@ def transfer_changes(self): rsync_command.append('--xattrs') # The following rsync option avoids including mounted external # drives like USB sticks in system backups. - # - # FIXME This will most likely be problematic for users with fancy - # partitioning schemes that e.g. mount /home to a different - # disk or partition. - rsync_command.append('--one-file-system') + if not self.multi_fs: + rsync_command.append('--one-file-system') # The following rsync options exclude irrelevant directories (to my # subjective mind) from the system backup. for pattern in self.excluded_roots: diff --git a/rsync_system_backup/cli.py b/rsync_system_backup/cli.py index b5a99bc..ad113f2 100644 --- a/rsync_system_backup/cli.py +++ b/rsync_system_backup/cli.py @@ -124,6 +124,11 @@ create a backup or snapshot but it does run rsync with the --dry-run option. + --multi-fs + + Allow rsync to cross filesystem boundaries. (has the opposite effect + of rsync option "-x, --one-file-system"). + -x, --exclude=PATTERN Selectively exclude certain files from being included in the backup. @@ -197,7 +202,7 @@ def main(): 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', 'exclude=', 'force', - 'disable-notifications', 'verbose', 'quiet', 'help', + 'disable-notifications', 'verbose', 'quiet', 'help', 'multi-fs', ]) for option, value in options: if option in ('-b', '--backup'): @@ -237,6 +242,8 @@ def main(): elif option in ('-x', '--exclude'): program_opts.setdefault('exclude_list', []) program_opts['exclude_list'].append(value) + elif option == '--multi-fs': + program_opts['multi_fs'] = True elif option == '--disable-notifications': program_opts['notifications_enabled'] = False elif option in ('-v', '--verbose'): From 5c4ec6ecd62c42c3f0805dd6afec8187ff56a3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fre=CC=81de=CC=81ric=20Calvez?= Date: Mon, 20 Aug 2018 17:06:58 +0200 Subject: [PATCH 2/2] Add cli arguments to make rsync more verbose --- rsync_system_backup/__init__.py | 14 ++++++++++++++ rsync_system_backup/cli.py | 25 ++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/rsync_system_backup/__init__.py b/rsync_system_backup/__init__.py index 347953c..fdc241d 100644 --- a/rsync_system_backup/__init__.py +++ b/rsync_system_backup/__init__.py @@ -293,6 +293,16 @@ def sudo_enabled(self): """:data:`True` to run ``rsync`` and snapshot creation with superuser privileges, :data:`False` otherwise.""" return True + @mutable_property + def rsync_verbose_count(self): + """:data: defaults to zero. Represents the number of -V arguments received""" + return 0 + + @mutable_property + def rsync_quiet_count(self): + """:data: defaults to zero. Represents the number of -Q arguments received""" + return 0 + def execute(self): """ Execute the requested actions (backup, snapshot and/or rotate). @@ -519,6 +529,10 @@ def transfer_changes(self): if self.dry_run: rsync_command.append('--dry-run') rsync_command.append('--verbose') + for _ in range(self.rsync_verbose_count): + rsync_command.append('--verbose') + for _ in range(self.rsync_quiet_count): + rsync_command.append('--quiet') # The following rsync options delete files in the backup # destination that no longer exist on the local system. # Due to snapshotting this won't cause data loss. diff --git a/rsync_system_backup/cli.py b/rsync_system_backup/cli.py index ad113f2..3a44990 100644 --- a/rsync_system_backup/cli.py +++ b/rsync_system_backup/cli.py @@ -150,11 +150,19 @@ -v, --verbose - Make more noise (increase logging verbosity). Can be repeated. + Make more noise (increase logging verbosity for the python app). Can be repeated. + + -V, --rsync-verbose + + Make the rsync program more noisy. Can be repeated. -q, --quiet - Make less noise (decrease logging verbosity). Can be repeated. + Make less noise (decrease logging verbosity for the python app). Can be repeated. + + -Q, --rsync-quiet + + Make the rsync program less noisy. -h, --help @@ -199,10 +207,11 @@ def main(): program_opts = dict() dest_opts = dict() try: - options, arguments = getopt.gnu_getopt(sys.argv[1:], 'bsrm:c:t:i:unx:fvqh', [ + options, arguments = getopt.gnu_getopt(sys.argv[1:], 'bsrm:c:t:i:unx:fvqhVQ', [ 'backup', 'snapshot', 'rotate', 'mount=', 'crypto=', 'tunnel=', 'ionice=', 'no-sudo', 'dry-run', 'exclude=', 'force', 'disable-notifications', 'verbose', 'quiet', 'help', 'multi-fs', + 'rsync-verbose', 'rsync-quiet', ]) for option, value in options: if option in ('-b', '--backup'): @@ -246,6 +255,16 @@ def main(): program_opts['multi_fs'] = True elif option == '--disable-notifications': program_opts['notifications_enabled'] = False + elif option in ('-V', '--rsync-verbose'): + if 'rsync_verbose_count' not in program_opts: + program_opts['rsync_verbose_count'] = 1 + else: + program_opts['rsync_verbose_count'] = program_opts['rsync_verbose_count'] + 1 + elif option in ('-Q', '--rsync-quiet'): + if 'rsync_quiet_count' not in program_opts: + program_opts['rsync_quiet_count'] = 1 + else: + program_opts['rsync_quiet_count'] = program_opts['rsync_quiet_count'] + 1 elif option in ('-v', '--verbose'): coloredlogs.increase_verbosity() elif option in ('-q', '--quiet'):