Skip to content

Commit

Permalink
Add cli arguments to make rsync more verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
clvz committed Aug 20, 2018
1 parent 518df84 commit 5c4ec6e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
14 changes: 14 additions & 0 deletions rsync_system_backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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.
Expand Down
25 changes: 22 additions & 3 deletions rsync_system_backup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'):
Expand Down Expand Up @@ -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'):
Expand Down

0 comments on commit 5c4ec6e

Please sign in to comment.