Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option "--rsync-option" #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions rsync_system_backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion rsync_system_backup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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'):
Expand Down