def send_notifications(self): # TODO(niklas9): # * make all magic values here part of settings or smth timestamp = utils.get_timestamp(fmt=self.NOTI_TIMESTAMP_FMT) subject = 'Backup %s successful <%s>' % (settings.BACKUP_SERVER_NAME, timestamp) body = ('%s\n\n%s\nTotal filesize: %s\nDatabases: %d' % (subject, self.filename, self.filesize, len(settings.BACKUP_MYSQL_DBS))) for email in settings.EMAIL_CONTACTS: self.log.debug('sending notification to <%s>..' % email) notification.Email.send(email, subject, body) self.log.debug('all notifications sent')
def sync(self, filename): # TODO(nandersson): # * add some logic so we only get backups from this server here, # e.g. match against server_name, suffix of 'tar.bz2' etc key_list = self.bucket.list(prefix=settings.AWS_DIR) for k in key_list: if self._get_backup_filename(k.key) == filename: continue remove_file = True k_date = self._get_backup_date(k.key) k_day = k_date[6:8] # fmt e.g.: 20130812 remove_file = not (settings.BACKUP_SAVE_EVERY_MONTH and k_day == self.FIRST_DAY_OF_MONTH) if remove_file: for i in range(settings.BACKUP_DAYS_TO_STORE): if k_date == utils.get_timestamp('%Y%m%d', i): remove_file = False break if remove_file: k.delete() self.log.debug('removed outdated backup <%s>' % k.key) self.log.debug('everything in sync')
def gen_filename(self): return self.FILENAME_FMT % (settings.BACKUP_SERVER_NAME, utils.get_timestamp(), settings.BACKUP_COMPRESSION_ALGO)
def gen_tmp_dir(self, path_fmt): return path_fmt % utils.get_timestamp()