Skip to content

Automated backups to S3 and restores #393

Description

@Tal-E

Use case

A ClickHouseCluster managed by the operator has no built-in way to be backed up or restored. Users who
need scheduled backups to S3 and a repeatable restore have to maintain their own CronJobs or sidecars
next to the operator, with their own credentials handling, status reporting and retention.

This is item 7 of the roadmap in #65 ("Automated backups to S3"). I would like to:

  • take a one-off backup of a cluster before a risky change,
  • run backups on a schedule, with a full backup followed by incremental backups,
  • restore a backup into the same cluster or into a new one, and
  • see the result of each of these in the status of a Kubernetes resource.

Describe the solution you'd like

Three new kinds in clickhouse.com/v1alpha1, separate from ClickHouseCluster so the existing API does
not change:

  • ClickHouseBackup: one backup of a cluster to S3, full or incremental (baseBackupRef), for
    everything except system or for selected databases and tables.
  • ClickHouseScheduledBackup: creates ClickHouseBackup resources on a cron schedule, with
    fullBackupInterval to alternate full and incremental backups and history limits for the created
    resources.
  • ClickHouseRestore: one restore, from a ClickHouseBackup or from a location in the storage.

The controllers use the native BACKUP / RESTORE ... ON CLUSTER ... ASYNC statements and poll
system.backups. The data goes from the ClickHouse pods to the storage directly, so there is no sidecar
or extra pod and the operator needs no access to the storage. Credentials come from a Secret, or from
the server itself (for example an IAM role of the ServiceAccount) when none are given.

I have an implementation of this and will open a pull request that links to this issue.

Describe alternatives you've considered

  • A clickhouse-backup sidecar and CronJobs. It needs an extra container in every replica with
    access to the data volume and the storage credentials, and the operator has no view of the result.
  • A backup section inside ClickHouseCluster. It would change the cluster API while the
    v1alpha2 API is being designed, and it does not model one-off backups and restores well. Separate
    kinds can be added without touching the cluster spec.
  • Reading system.backup_log instead of system.backups. The log survives restarts, but the
    operator does not enable it today and enabling it would restart existing clusters.

Additional context

Open questions where maintainer direction would help:

  • Whether the new kinds should target v1alpha1 now or wait for v1alpha2.
  • Whether deleting backup data from the storage (retention) should be done by the operator or left to
    bucket lifecycle rules. The proposed implementation leaves it to the bucket.
  • Whether a running operation should be cancelled when its resource is deleted.

Activity

  1. Tal-E commented on Dec 1, 2026

    @Tal-E
    Author

    @GrigoryPervakov thank you for looking at this and for setting the type and the feature label.

    There is a PR that implements it: #394. It adds ClickHouseBackup, ClickHouseScheduledBackup and ClickHouseRestore, built on the native BACKUP / RESTORE ... ON CLUSTER statements with S3 storage.

    I merged the current main into it today (it had a conflict in PROJECT) and adapted it to the Pod IP connections and to the logging and constants rules in docs/development.md. make lint, make test and the backup e2e spec pass locally. The workflow runs on the PR are waiting for approval.

    I'm happy to change the API or split the PR if you would prefer a different shape.

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

    feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions