Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
970d3dde1e
|
|||
4d23bde906
|
@ -59,6 +59,25 @@ Default behavior is to remove old backups after successfully completing the back
|
|||||||
.TP
|
.TP
|
||||||
.B \-\-no\-syslog
|
.B \-\-no\-syslog
|
||||||
Don't use systemd journal for logging
|
Don't use systemd journal for logging
|
||||||
|
.TP
|
||||||
|
.B \-\-rsync\-options OPTIONS [OPTION...]
|
||||||
|
By default, the following rsync options are used:
|
||||||
|
.RS
|
||||||
|
.PP
|
||||||
|
\-a \-r \-c \-v \-h \-H \-X
|
||||||
|
.PP
|
||||||
|
Using \-\-rsync\-options it is possible to manually select which options to use. Supported values are the following:
|
||||||
|
.PP
|
||||||
|
\-a, \-l, \-p, \-t, \-g, \-o, \-c, \-h, \-D, \-H, \-X
|
||||||
|
.PP
|
||||||
|
Options \-r and \-v are used in any case. Not that options must be specified without dash (\-), for example:
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
simple_backup \-\-rsync\-options a l p
|
||||||
|
.EE
|
||||||
|
.TP
|
||||||
|
Check rsync(1) for details about the options.
|
||||||
|
.RE
|
||||||
.SH CONFIGURATION
|
.SH CONFIGURATION
|
||||||
An example configuration file is provided at \(aq/etc/simple_backup/simple_backup.conf\(aq. Copy it to the default location
|
An example configuration file is provided at \(aq/etc/simple_backup/simple_backup.conf\(aq. Copy it to the default location
|
||||||
($HOME/.config/simple_backup) and edit it as needed.
|
($HOME/.config/simple_backup) and edit it as needed.
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
"""Init."""
|
"""Init."""
|
||||||
|
|
||||||
__version__ = '3.4.0'
|
__version__ = '3.5.0'
|
||||||
|
@ -186,12 +186,28 @@ class Backup:
|
|||||||
self.create_backup_dir()
|
self.create_backup_dir()
|
||||||
|
|
||||||
_, self._inputs_path = mkstemp(prefix='tmp_inputs', text=True)
|
_, self._inputs_path = mkstemp(prefix='tmp_inputs', text=True)
|
||||||
_, self._exclude_path = mkstemp(prefix='tmp_exclude', text=True)
|
count = 0
|
||||||
|
|
||||||
with open(self._inputs_path, 'w') as fp:
|
with open(self._inputs_path, 'w') as fp:
|
||||||
for i in self.inputs:
|
for i in self.inputs:
|
||||||
|
if not os.path.exists(i):
|
||||||
|
logger.warning(f'Input {i} not found. Skipping')
|
||||||
|
else:
|
||||||
fp.write(i)
|
fp.write(i)
|
||||||
fp.write('\n')
|
fp.write('\n')
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
if count == 0:
|
||||||
|
logger.info('No existing files or directories specified for backup. Nothing to do')
|
||||||
|
|
||||||
|
try:
|
||||||
|
notify('Backup finished. No files copied')
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return 1
|
||||||
|
|
||||||
|
_, self._exclude_path = mkstemp(prefix='tmp_exclude', text=True)
|
||||||
|
|
||||||
with open(self._exclude_path, 'w') as fp:
|
with open(self._exclude_path, 'w') as fp:
|
||||||
if self.exclude is not None:
|
if self.exclude is not None:
|
||||||
@ -267,6 +283,9 @@ def _parse_arguments():
|
|||||||
parser.add_argument('--remove-before-backup', action='store_true',
|
parser.add_argument('--remove-before-backup', action='store_true',
|
||||||
help='Remove old backups before executing the backup, instead of after')
|
help='Remove old backups before executing the backup, instead of after')
|
||||||
parser.add_argument('--no-syslog', action='store_true', help='Disable systemd journal logging')
|
parser.add_argument('--no-syslog', action='store_true', help='Disable systemd journal logging')
|
||||||
|
parser.add_argument('--rsync-options', nargs='+',
|
||||||
|
choices=['a', 'l', 'p', 't', 'g', 'o', 'c', 'h', 'D', 'H', 'X'],
|
||||||
|
help='Specify options for rsync')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@ -353,12 +372,21 @@ def simple_backup():
|
|||||||
if args.keep is not None:
|
if args.keep is not None:
|
||||||
keep = args.keep
|
keep = args.keep
|
||||||
|
|
||||||
|
if args.rsync_options is None:
|
||||||
if args.checksum:
|
if args.checksum:
|
||||||
backup_options = '-arcvh -H -X'
|
rsync_options = '-arcvh -H -X'
|
||||||
else:
|
else:
|
||||||
backup_options = '-arvh -H -X'
|
rsync_options = '-arvh -H -X'
|
||||||
|
else:
|
||||||
|
rsync_options = '-r -v '
|
||||||
|
|
||||||
backup = Backup(inputs, output, exclude, keep, backup_options, remove_before=args.remove_before_backup)
|
for ro in args.rsync_options:
|
||||||
|
rsync_options = rsync_options + f'-{ro} '
|
||||||
|
|
||||||
|
if '-c ' not in rsync_options and args.checksum:
|
||||||
|
rsync_options = rsync_options + '-c'
|
||||||
|
|
||||||
|
backup = Backup(inputs, output, exclude, keep, rsync_options, remove_before=args.remove_before_backup)
|
||||||
|
|
||||||
return_code = backup.check_params()
|
return_code = backup.check_params()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user