Beispiel #1
0
    def apply_retention_policy(self, dst, config, run_type, status):
        """
        Delete old backup copies.

        :param dst: Destination where the backups are stored.
        :type dst: BaseDestination
        :param config: Tool configuration
        :type config: TwinDBBackupConfig
        :param run_type: Run type.
        :type run_type: str
        :param status: Backups status.
        :type status: Status
        :return: Updated status.
        :rtype: Status
        """

        prefix = osp.join(dst.remote_path, self.get_prefix(), "mysql")
        keep_copies = getattr(config.retention, run_type)

        backups_list = dst.list_files(prefix, files_only=True)
        LOG.debug("Remote copies: %r", backups_list)
        for backup_file in get_files_to_delete(backups_list, keep_copies):
            LOG.debug("Deleting remote file %s", backup_file)
            dst.delete(backup_file)
            try:
                status.remove(backup_file)

            except StatusKeyNotFound as err:
                LOG.warning(err)
                LOG.debug("Status: %r", status)

        self._delete_local_files("mysql", config)

        return status
Beispiel #2
0
    def apply_retention_policy(self, dst, config, run_type, status):
        """
        Delete old backup copies.

        :param dst: Destination where the backups are stored.
        :type dst: BaseDestination
        :param config: Tool configuration
        :type config: ConfigParser.ConfigParser
        :param run_type: Run type.
        :type run_type: str
        :param status: Backups status.
        :type status: Status
        :return: Updated status.
        :rtype: Status
        """

        prefix = "{remote_path}/{prefix}/mysql/mysql-".format(
            remote_path=dst.remote_path, prefix=self.get_prefix())
        keep_copies = config.getint('retention', '%s_copies' % run_type)

        backups_list = dst.list_files(prefix)
        LOG.debug('Remote copies: %r', backups_list)
        for backup_copy in get_files_to_delete(backups_list, keep_copies):
            LOG.debug('Deleting remote file %s', backup_copy)
            dst.delete(backup_copy)
            try:
                status.remove(run_type, dst.basename(backup_copy))
            except StatusKeyNotFound as err:
                LOG.warning(err)
                LOG.debug('Status: %r', status)

        self._delete_local_files('mysql', config)

        return status
Beispiel #3
0
    def apply_retention_policy(self, dst, config, run_type, status):
        """
        Delete old backup copies.

        :param dst: Destination where the backups are stored.
        :type dst: BaseDestination
        :param config: Tool configuration
        :type config: ConfigParser.ConfigParser
        :param run_type: Run type.
        :type run_type: str
        :param status: Backups status.
        :type status: dict
        :return: Updated status.
        :rtype: dict
        """

        prefix = "{remote_path}/{prefix}/mysql/mysql-".format(
            remote_path=dst.remote_path, prefix=self.get_prefix())
        keep_copies = config.getint('retention', '%s_copies' % run_type)

        objects = dst.list_files(prefix)

        for backup_copy in get_files_to_delete(objects, keep_copies):
            LOG.debug('Deleting remote file %s', backup_copy)
            dst.delete(backup_copy)
            status = self._delete_from_status(status, dst.remote_path,
                                              backup_copy)

        self._delete_local_files('mysql', config)

        return status
Beispiel #4
0
    def apply_retention_policy(self, dst, config, run_type):
        """Apply retention policy"""
        prefix = "{remote_path}/{prefix}/files/{file}".format(
            remote_path=dst.remote_path,
            prefix=self.get_prefix(),
            file=self._sanitize_filename())
        keep_copies = config.getint('retention', '%s_copies' % run_type)

        backups_list = dst.list_files(prefix)

        LOG.debug('Remote copies: %r', backups_list)
        for backup_copy in get_files_to_delete(backups_list, keep_copies):
            LOG.debug('Deleting remote file %s', backup_copy)
            dst.delete(backup_copy)

        self._delete_local_files(self._sanitize_filename(), config)
Beispiel #5
0
    def apply_retention_policy(self, dst, config, run_type):
        """Apply retention policy
        """
        prefix = "{remote_path}/{prefix}/files/{file}".format(
            remote_path=dst.remote_path,
            prefix=self.get_prefix(),
            file=self._sanitize_filename()
        )
        keep_copies = getattr(config.retention, run_type)

        backups_list = dst.list_files(prefix)

        LOG.debug('Remote copies: %r', backups_list)
        for backup_copy in get_files_to_delete(backups_list, keep_copies):
            LOG.debug('Deleting remote file %s', backup_copy)
            dst.delete(backup_copy)

        self._delete_local_files(self._sanitize_filename(), config)
Beispiel #6
0
    def apply_retention_policy(self, dst, config, run_type, status):
        """
        Delete old backup copies.

        :param dst: Destination where the backups are stored.
        :type dst: BaseDestination
        :param config: Tool configuration
        :type config: TwinDBBackupConfig
        :param run_type: Run type.
        :type run_type: str
        :param status: Backups status.
        :type status: Status
        :return: Updated status.
        :rtype: Status
        """

        prefix = osp.join(
            dst.remote_path,
            self.get_prefix(),
            'mysql'
        )
        keep_copies = getattr(config.retention, run_type)

        backups_list = dst.list_files(
            prefix,
            files_only=True
        )
        LOG.debug('Remote copies: %r', backups_list)
        for backup_file in get_files_to_delete(backups_list, keep_copies):
            LOG.debug('Deleting remote file %s', backup_file)
            dst.delete(backup_file)
            try:
                status.remove(backup_file)

            except StatusKeyNotFound as err:
                LOG.warning(err)
                LOG.debug('Status: %r', status)

        self._delete_local_files('mysql', config)

        return status