Skip to content

Support BACKUP and RESTORE of named collections - #126028

Merged
jkartseva merged 24 commits into
ClickHouse:masterfrom
eliangidoni:elian/backupnc
Nov 3, 2026
Merged

jkartseva merged 24 commits into
ClickHouse:masterfrom
eliangidoni:elian/backupnc

Conversation

@eliangidoni

@eliangidoni eliangidoni commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

A backup could fail to restore if the table/schema references a named collection. This PR includes the named collections in a backup/restore.

  • Backing up requires SHOW NAMED COLLECTIONS and SHOW NAMED COLLECTIONS SECRETS - also with an encrypted storage.
  • Restoring requires CREATE NAMED COLLECTION (and DROP NAMED COLLECTION for the 'replace' mode).
  • New RESTORE settings: restore_named_collections (table whose engine references a collection cannot be created without it) and create_named_collection.

Changelog category (leave one):

  • New Feature

Changelog entry:

  • Include named collections in backups/restores

Workflow [PR]
Sync PR [sync-upstream/pr/126028]

Version info

  • Merged into: 26.11.1.1168-master (included in 26.11 and later)

@eliangidoni
eliangidoni requested a review from jkartseva October 15, 2026 13:29
@eliangidoni eliangidoni added the can be tested Allows running workflows for external contributors label Oct 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e55b632]

Summary: ✅


AI Review

Summary

The PR adds BACKUP and RESTORE support for SQL-created named collections through system.named_collections, including export privileges, authenticated encrypted entries, and replicated coordination. Reviewed head e55b6320853c8422d71b20da685ad5f92352c7a8 and all prior discussion. The current code addresses the previous bot findings; no new actionable findings remain.

Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 15, 2026
Comment thread src/Backups/RestorerFromBackup.cpp Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-backup Backup/restore infrastructure and backup formats. label Oct 15, 2026
@jkartseva jkartseva self-assigned this Oct 15, 2026
Comment thread src/Backups/BackupsWorker.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing e55b63208 with master cd3eb1781 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 2169e8bff; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

43 object files changed (+333.63 KiB total), 2 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Common/NamedCollections/NamedCollectionsBackup.cpp.o new 160.79 KiB +160.79 KiB
src/CMakeFiles/dbms.dir/Backups/BackupCoordinationReplicatedNamedCollections.cpp.o new 36.86 KiB +36.86 KiB
src/CMakeFiles/dbms.dir/Common/NamedCollections/NamedCollectionsMetadataStorage.cpp.o 308.50 KiB 344.33 KiB +35.83 KiB (+11.61%)
src/CMakeFiles/dbms.dir/Backups/BackupCoordinationOnCluster.cpp.o 499.01 KiB 520.51 KiB +21.50 KiB (+4.31%)
src/CMakeFiles/dbms.dir/Backups/BackupsWorker.cpp.o 580.75 KiB 600.87 KiB +20.12 KiB (+3.46%)
src/CMakeFiles/dbms.dir/Interpreters/InterpreterCreateNamedCollectionQuery.cpp.o 59.07 KiB 40.13 KiB -18.94 KiB (-32.06%)
src/CMakeFiles/dbms.dir/Backups/RestoreCoordinationLocal.cpp.o 69.45 KiB 87.16 KiB +17.71 KiB (+25.51%)
src/CMakeFiles/dbms.dir/Backups/RestoreCoordinationOnCluster.cpp.o 234.02 KiB 251.53 KiB +17.51 KiB (+7.48%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

398 translation units recompiled, 3290 s compile time in total, 396 of them have a recent master baseline.

Translation units without a recent master baseline:

  • src/Common/NamedCollections/NamedCollectionsBackup.cpp: 5.5 s

Job report

Comment thread src/Backups/BackupUtils.cpp Resolved
Comment thread src/Backups/BackupsWorker.cpp Resolved
Comment thread src/Backups/RestorerFromBackup.cpp Resolved
Comment thread src/Backups/BackupsWorker.cpp Resolved
/// against the initiating user (see `BackupsWorker`), because this host may be running the
/// query with full access.
auto access = context->getAccess();
if (!access->isGranted(show_values_rights) || !access->isGranted(AccessType::displaySecretsInShowAndSelect))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may also need context->displaySecretsInShowAndSelect() which checks a server setting display_secrets_in_show_and_select = 0, and it cannot be changed by a user. Yet I'm not sure about this: it would mean backup_named_collections = 1 cannot override it and an operator who disabled the setting could never back up collections at all. IMO it needs some internal discussion.

Comment thread src/Backups/BackupsWorker.cpp Resolved
Comment thread src/Backups/BackupUtils.cpp Resolved
Comment thread src/Backups/BackupEntriesCollector.cpp Resolved
Comment thread src/Backups/RestorerFromBackup.cpp Resolved

@jkartseva jkartseva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM;
@eliangidoni Please change the category to a New Feature instead of Bug fix and document the key aspects in docs/concepts/features/backup-restore/, specifically the new settings.

@mintlify

mintlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Preview approved

@PedroTadim approved a Mintlify preview for commit e55b632.

@clickhouse-gh clickhouse-gh Bot added pr-feature Pull request with new product feature and removed pr-bugfix Pull request with bugfix, not backported by default labels Oct 28, 2026
@mintlify

mintlify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Nov 2, 2026, 1:04 PM

This branch was successfully deployed

1 active deployment
staging - docs — e55b6320 Deployed Nov 2, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-backup Backup/restore infrastructure and backup formats. pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants