IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 24, 2019, 1:19:12 PM (7 years ago)
Author:
fairlamb
Message:

Backups write out a tiny log saying when it was last run

File:
1 edited

Legend:

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

    r40962 r40966  
    115115
    116116    def run_backup_processes(self):
    117 
     117        self._write_begin_log()
    118118        if self.should_run_copy:
    119119            self._run_copy()
     
    124124        if self.should_run_mysqldump:
    125125            self._run_mysqldump()
     126        self._write_end_log()
    126127
    127128    def hostname_is_valid(self) -> bool:
     
    260261        return 0
    261262
     263    def _write_begin_log(self):
     264        backup_paths = self.default_dict["backup_paths"]
     265        for bp in backup_paths:
     266            log_file = path.join(bp, "latest_run.log")
     267            if path.exists(log_file):
     268                os.remove(log_file)
     269            with open(log_file, "w+") as lf:
     270                lf.write(f'Run started at: {datetime.date.today().strftime("%Y_%b_%d_%H:%M")}\n')
     271
     272    def _write_end_log(self):
     273        backup_paths = self.default_dict["backup_paths"]
     274        for bp in backup_paths:
     275            log_file = path.join(bp, "latest_run.log")
     276            if not path.exists(log_file):
     277                return
     278            with open(log_file, "a") as lf:
     279                lf.write(f'Last successful backup completed at : {datetime.date.today().strftime("%Y_%b_%d_%H:%M")}\n')
     280
    262281
    263282def get_date(custom_date=None, custom_format="%Y_%m_%d"):
Note: See TracChangeset for help on using the changeset viewer.