Make inputs and backup_dir optional in the config file
They can come from -i and -o; missing ones were rejected as a bad configuration file (exit code 6).
This commit is contained in:
@@ -946,19 +946,22 @@ def _read_config(config_file: str, user: str | None = None) -> ConfigArgs:
|
||||
config = configparser.ConfigParser(interpolation=None)
|
||||
config.read(config_file)
|
||||
|
||||
section = 'backup'
|
||||
|
||||
# Allow compatibility with previous version of config file
|
||||
try:
|
||||
inputs = config.get(section, 'inputs')
|
||||
except configparser.NoSectionError:
|
||||
if config.has_section('backup'):
|
||||
section = 'backup'
|
||||
elif config.has_section('default'):
|
||||
section = 'default'
|
||||
inputs = config.get(section, 'inputs')
|
||||
else:
|
||||
raise configparser.NoSectionError('backup')
|
||||
|
||||
config_args['inputs'] = list(set(_expand_inputs([i.strip() for i in inputs.split(',')], user)))
|
||||
# inputs and backup_dir are optional, since -i and -o can give them. Missing ones are reported by check_params()
|
||||
inputs = config.get(section, 'inputs', fallback=None)
|
||||
|
||||
if inputs is not None:
|
||||
config_args['inputs'] = list(set(_expand_inputs([i.strip() for i in inputs.split(',')], user)))
|
||||
|
||||
# '~' is expanded later, since for remote backups it refers to the home on the server
|
||||
config_args['output'] = config.get(section, 'backup_dir')
|
||||
config_args['output'] = config.get(section, 'backup_dir', fallback=None)
|
||||
|
||||
exclude = config.get(section, 'exclude', fallback='')
|
||||
config_args['exclude'] = [e.strip() for e in exclude.split(',') if e.strip() != '']
|
||||
|
||||
Reference in New Issue
Block a user