Improve readability
This commit is contained in:
parent
cd558e8608
commit
b34627fe58
@ -420,12 +420,10 @@ class Backup:
|
|||||||
|
|
||||||
if self._last_backup == '':
|
if self._last_backup == '':
|
||||||
rsync = f'/usr/bin/rsync {self.options} --exclude-from={self._exclude_path} ' +\
|
rsync = f'/usr/bin/rsync {self.options} --exclude-from={self._exclude_path} ' +\
|
||||||
f'--files-from={self._inputs_path} / "{self._server}{self._output_dir}" ' +\
|
f'--files-from={self._inputs_path} / "{self._server}{self._output_dir}"'
|
||||||
'--ignore-missing-args --mkpath --protect-args'
|
|
||||||
else:
|
else:
|
||||||
rsync = f'/usr/bin/rsync {self.options} --link-dest="{self._last_backup}" --exclude-from=' +\
|
rsync = f'/usr/bin/rsync {self.options} --link-dest="{self._last_backup}" --exclude-from=' +\
|
||||||
f'{self._exclude_path} --files-from={self._inputs_path} / "{self._server}{self._output_dir}" ' +\
|
f'{self._exclude_path} --files-from={self._inputs_path} / "{self._server}{self._output_dir}"'
|
||||||
'--ignore-missing-args --mkpath --protect-args'
|
|
||||||
|
|
||||||
if euid == 0 and self.ssh_keyfile is not None:
|
if euid == 0 and self.ssh_keyfile is not None:
|
||||||
rsync = f'{rsync} -e \'ssh -i {self.ssh_keyfile}\''
|
rsync = f'{rsync} -e \'ssh -i {self.ssh_keyfile}\''
|
||||||
@ -520,10 +518,13 @@ def _read_config(config_file):
|
|||||||
try:
|
try:
|
||||||
host = config.get('server', 'host')
|
host = config.get('server', 'host')
|
||||||
username = config.get('server', 'username')
|
username = config.get('server', 'username')
|
||||||
ssh_keyfile = config.get('server', 'ssh_keyfile')
|
|
||||||
except (configparser.NoSectionError, configparser.NoOptionError):
|
except (configparser.NoSectionError, configparser.NoOptionError):
|
||||||
host = None
|
host = None
|
||||||
username = None
|
username = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
ssh_keyfile = config.get('server', 'ssh_keyfile')
|
||||||
|
except (configparser.NoSectionError, configparser.NoOptionError):
|
||||||
ssh_keyfile = None
|
ssh_keyfile = None
|
||||||
|
|
||||||
return inputs, output, exclude, keep, host, username, ssh_keyfile
|
return inputs, output, exclude, keep, host, username, ssh_keyfile
|
||||||
@ -551,7 +552,7 @@ def simple_backup():
|
|||||||
"""Main"""
|
"""Main"""
|
||||||
|
|
||||||
args = _parse_arguments()
|
args = _parse_arguments()
|
||||||
inputs, output, exclude, keep, username, host, ssh_keyfile = _read_config(args.config)
|
inputs, output, exclude, keep, host, username, ssh_keyfile = _read_config(args.config)
|
||||||
|
|
||||||
if args.input is not None:
|
if args.input is not None:
|
||||||
inputs = args.input
|
inputs = args.input
|
||||||
@ -574,7 +575,7 @@ def simple_backup():
|
|||||||
if args.keyfile is not None:
|
if args.keyfile is not None:
|
||||||
ssh_keyfile = args.keyfile
|
ssh_keyfile = args.keyfile
|
||||||
|
|
||||||
backup_options = ['-a', '-r', '-v', '-h', '-H', '-X']
|
backup_options = ['-a', '-r', '-v', '-h', '-H', '-X', '-s', '--ignore-missing-args', '--mkpath']
|
||||||
|
|
||||||
if args.checksum:
|
if args.checksum:
|
||||||
backup_options.append('-c')
|
backup_options.append('-c')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user