Skip to content

Feature Request: Support deleting DatabaseCluster while retaining backups #943

Description

@Vinh1507

Hi,
I would like to propose a new feature that allows deleting a DatabaseCluster while intentionally retaining its DatabaseClusterBackup objects and associated data on object storage (S3/Azure Blob), so that backups can be used to restore data into a new cluster later.

Feature Request

Current Behavior

When a DatabaseCluster is deleted, all associated DatabaseClusterBackup objects are always deleted via two mechanisms:

1. Operator explicitly deletes backups

In HandleDBBackupsCleanup, the operator actively calls deleteBackupsForDatabase which deletes all DatabaseClusterBackup objects before proceeding with cluster deletion.

2. Kubernetes GC cascade via ownerReferences

Every DatabaseClusterBackup has an ownerReference with blockOwnerDeletion: true pointing to its DatabaseCluster. Once the DatabaseCluster CR is fully gone, Kubernetes GC automatically deletes all owned backups - even when using kubectl delete --cascade=orphan.

Expected Behavior

Users should be able to delete a DatabaseCluster while retaining its DatabaseClusterBackup objects and the associated backup data on object storage, so that they can restore into a new cluster later.

This is a common pattern in managed database services - for example AWS RDS supports "retain automated backups" when deleting a DB instance.

Proposed Solution

Introduce an annotation everest.percona.com/keep-backups: "true" on DatabaseCluster:

apiVersion: everest.percona.com/v1alpha1
kind: DatabaseCluster
metadata:
  name: my-cluster
  annotations:
    everest.percona.com/keep-backups: "true"

When this annotation is present during deletion:

  1. Skip deleteBackupsForDatabase in HandleDBBackupsCleanup
  2. Skip the len(backupList.Items) != 0 check in HandleUpstreamClusterCleanup
  3. Maybe detach ownerReference from all DatabaseClusterBackup objects before the DatabaseCluster CR is fully gone, so Kubernetes GC does not cascade delete them

After deletion, retained backups can be used to restore into a new cluster via DatabaseClusterRestore:

apiVersion: everest.percona.com/v1alpha1
kind: DatabaseClusterRestore
metadata:
  name: restore-from-retained-backup
spec:
  dbClusterName: my-new-cluster
  dataSource:
    dbClusterBackupName: my-retained-backup

Additional Context

  • Restoring from a retained backup requires only the DatabaseClusterBackup CR and the BackupStorage CR - the original DatabaseCluster is not needed
  • DatabaseClusterBackup.spec.dbClusterName already captures the cluster relationship via field index, so removing ownerReference does not break any query or reconcile logic

Thank you

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions