IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 9, 2019, 2:15:34 PM (7 years ago)
Author:
fairlamb
Message:

Added local rsync to subprocess and how to handle it in backups (functionally the same as cp)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ipp-259_genericise_backups/tools/backups/backup.py

    r40931 r40932  
    181181
    182182    def _run_rsync(self):
    183         raise Exception("Not implemented")
     183        if self.run_rsync is None or False:
     184            return 0
     185
     186        backup_paths = self.default_dict['backup_paths']
     187        for bp in backup_paths:
     188            if not path.exists(bp):
     189                raise errs.ValidationError(f"ValidationError: target path does not exist: {bp}")
     190
     191            for s in self.rsync_dict['sources']:
     192                if not path.exists(s):
     193                    raise errs.ValidationError(f"ValidationError: target path does not exist: {s}")
     194                try:
     195                    args = [s, bp]
     196                    if 'additional_args' in self.rsync_dict.keys():
     197                        print("hiya")
     198                        args = args + self.rsync_dict['additional_args']
     199                        print(args)
     200                    sub_utils.local_rsync_wrapper(args)
     201                except errs.SubprocessError as e:
     202                    raise errs.SubprocessError( f"Error: rsync\n"
     203                                                f"    from: {s}\n"
     204                                                f"    to: {bp}\n"
     205                                              ) from e
     206        return 0
    184207
    185208    def _run_mysqldump(self):
    186209
    187         # cfg_help.ConfigSchemaLine('user', True, str)
    188         # cfg_help.ConfigSchemaLine('password', True, str)
    189         # cfg_help.ConfigSchemaLine('db_name', True, str)
    190         # cfg_help.ConfigSchemaLine('additional_args', False, list, cfg_help.SpecialSchemaProcessing.space_separated)
    191         # cfg_help.ConfigSchemaLine('target_filename', True, str)
    192         # cfg_help.ConfigSchemaLine('prefix_date', True, bool)
    193 
    194210        backup_paths = self.default_dict['backup_paths']
    195211
    196         # Setup the commands:
    197212        mysqldump_args = [ 'mysqldump'
    198213                         , '-u', self.mysqldump_dict['user']
Note: See TracChangeset for help on using the changeset viewer.