Changeset 41067 for trunk/backups/backup.py
- Timestamp:
- Nov 5, 2019, 3:18:35 PM (7 years ago)
- Location:
- trunk/backups
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/backups
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/IPP-308_move_backups_folder/backups merged eligible /branches/ipp-350_add_to_jira_conf_backups merged eligible /trunk/backups merged eligible /branches/czw_branch/20160809/backups 39651-39924 /branches/czw_branch/20170908/backups 40128-40486 /branches/ipp-259_genericise_backups/backups 40910-40966
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/backups/backup.py
r40973 r41067 33 33 [ ConfigSchemaLine('sources', True, list, SpecialSchemaProcessing.commma_separated) 34 34 , ConfigSchemaLine('additional_args', False, list, SpecialSchemaProcessing.space_separated) 35 , ConfigSchemaLine('sub-dirs', False, list, SpecialSchemaProcessing.commma_separated) 35 36 ] 36 37 ) … … 83 84 84 85 self.read_config_and_schema(config, schema) 85 # self.read_copy_config_section(config, schema)86 # self.read_tar_config_section(config, schema)87 # self.read_rsync_config_section(config, schema)88 # self.read_mysqldump_config_section(config, schema)89 86 90 87 def read_config_and_schema(self, config: ConfigParser, schema: ConfigSchema): … … 206 203 self.target_backup_paths_ok(raise_error=True) 207 204 backup_paths = self.default_dict['backup_paths'] 208 for bp in backup_paths: 209 # if not path.exists(bp): 210 # raise errs.ValidationError(f"ValidationError: target path does not exist: {bp}") 211 212 for s in self.rsync_dict['sources']: 213 if not path.exists(s): 214 raise errs.ValidationError(f"ValidationError: target path does not exist: {s}") 205 206 sources = self.rsync_dict['sources'] 207 for i in range(0, len(sources)): 208 source = sources[i] 209 if not path.exists(source): 210 raise errs.ValidationError(f"ValidationError: target path does not exist: {source}") 211 212 for bp in backup_paths: 215 213 try: 216 a rgs = [s, bp]214 additional_args = [] 217 215 if 'additional_args' in self.rsync_dict.keys(): 218 args = args + self.rsync_dict['additional_args'] 216 additional_args = self.rsync_dict['additional_args'] 217 218 source_and_target_args = [source, bp] 219 220 # sub-dirs option allows items to be backed up to subdirs within 221 # the source for better naming 222 if 'sub-dirs' in self.rsync_dict: 223 sub_dirs = self.rsync_dict['sub-dirs'] 224 if len(sub_dirs) != len(sources): 225 raise errs.ValidationError(f"ValidationError: if using " + 226 "subdirs the number of subdirs must equal the number of sources") 227 bp_with_subdir = os.path.join(bp, sub_dirs[i]) 228 if not os.path.exists(bp_with_subdir): 229 os.makedirs(bp_with_subdir) 230 source_and_target_args = [source, bp_with_subdir] 231 232 args = source_and_target_args + additional_args 219 233 sub_utils.local_rsync_wrapper(args) 234 220 235 except errs.SubprocessError as e: 221 236 raise errs.SubprocessError( f"Error: rsync\n" 222 f" from: {s }\n"223 f" to: { bp}\n"237 f" from: {source_and_target_args[0]}\n" 238 f" to: {source_and_target_args[1]}\n" 224 239 ) from e 225 240 return 0
Note:
See TracChangeset
for help on using the changeset viewer.
