config.py

changeset 21
c36e549a7f12
parent 4
d72c4844e791
child 22
c3e95212e3f0
equal deleted inserted replaced
20:fdfbe5d7b677 21:c36e549a7f12
13 # 13 #
14 # Defaults 14 # Defaults
15 # 15 #
16 16
17 defaults={ 17 defaults={
18 # Default: backup every 6 hours (21600 seconds) 18 # borg
19 'backup_interval': 21600, 19 # Default: backup every 6 hours (21600 seconds)
20 # Default: retry every 15 minutes if unable to connect / unfinished backup 20 'backup_interval': 21600,
21 'retry_interval': 900, 21 # Default: retry every 15 minutes if unable to connect / unfinished backup
22 # borg 22 'retry_interval': 900,
23 'borg': { 23 # Extract passphrases at startup or on demand?
24 'executable': 'borg', 24 '__extract_passphrases_at_startup': True,
25 'common_parameters': [], 25 # Borg settings
26 'create_parameters': [], 26 'borg': {
27 'prune_parameters': [], 27 'executable': 'borg',
28 'common_parameters': [],
29 'create_parameters': [],
30 'prune_parameters': [],
28 } 31 }
29 } 32 }
30 33
31 34
32 # 35 #
123 126
124 # 127 #
125 # Verify basic settings 128 # Verify basic settings
126 # 129 #
127 130
128 if 'borg' not in settings: 131 def check_and_set(cfg, field, loc, defa, fn):
129 settings['borg']=defaults['borg'] 132 cfg[field]=fn(cfg, field, field, loc, defa[field])
130 else:
131 def check_and_set(cfg, field, loc, defa, fn):
132 cfg[field]=fn(cfg, field, field, loc, defa[field])
133 return cfg
134 133
135 def check_parameters(cmd): 134 def check_parameters(cmd):
136 settings['borg']=check_and_set(settings['borg'], cmd+'_parameters', 135 check_and_set(settings['borg'], cmd+'_parameters',
137 'borg', defaults['borg'], 136 'borg', defaults['borg'],
138 check_list_of_dicts) 137 check_list_of_dicts)
139 138
140 settings['borg']=check_and_set(settings['borg'], 'executable', 'borg', 139 check_and_set(settings, 'backup_interval', 'top-level', defaults, check_nonneg_int)
141 defaults['borg'], check_string) 140 check_and_set(settings, 'retry_interval', 'top-level', defaults, check_nonneg_int)
141 check_and_set(settings, '__extract_passphrases_at_startup', 'top-level', defaults, check_nonneg_int)
142 check_and_set(settings, 'borg', 'top-level', defaults, check_dict)
143 # Check parameters within 'borg'
144 if True:
145 check_and_set(settings['borg'], 'executable', 'borg',
146 defaults['borg'], check_string)
142 147
143 check_parameters('common') 148 check_parameters('common')
144 check_parameters('create') 149 check_parameters('create')
145 check_parameters('prune') 150 check_parameters('prune')
146 151

mercurial