Skip to content

Update export-backups-to-own-cloud-account.md #3688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

linhgiang24
Copy link
Contributor

The command to restore from backup is incorrect. The correct command should be:

RESTORE DATABASE test_backups_restored 
AS test_backups 
FROM S3('https://testchbackups.s3.amazonaws.com/backups/<uuid>', '<key id>', '<key secret>')

The command to restore from backup is incorrect.  The correct command should be:
RESTORE DATABASE test_backups_restored 
AS test_backups 
FROM S3('https://testchbackups.s3.amazonaws.com/backups/<uuid>', '<key id>', '<key secret>')
@linhgiang24 linhgiang24 requested a review from a team as a code owner April 16, 2025 19:03
Copy link

vercel bot commented Apr 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clickhouse-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 16, 2025 7:12pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
clickhouse-docs-jp ⬜️ Ignored (Inspect) Apr 16, 2025 7:12pm
clickhouse-docs-ru ⬜️ Ignored (Inspect) Apr 16, 2025 7:12pm
clickhouse-docs-zh ⬜️ Ignored (Inspect) Apr 16, 2025 7:12pm

@linhgiang24
Copy link
Contributor Author

Actually, as I was reviewing the document again, all the restore from backup commands are incorrect - not just the one that I fixed.

From public documentation:

BACKUP|RESTORE
  TABLE [db.]table_name [AS [db.]table_name_in_backup]
    [PARTITION[S] partition_expr [,...]] |
  DICTIONARY [db.]dictionary_name [AS [db.]name_in_backup] |
  DATABASE database_name [AS database_name_in_backup]
    [EXCEPT TABLES ...] |
  TEMPORARY TABLE table_name [AS table_name_in_backup] |
  VIEW view_name [AS view_name_in_backup]
  ALL TEMPORARY TABLES [EXCEPT ...] |
  ALL [EXCEPT ...] } [,...]
  [ON CLUSTER 'cluster_name']
  TO|FROM File('<path>/<filename>') | Disk('<disk_name>', '<path>/') | S3('<S3 endpoint>/<path>', '<Access key ID>', '<Secret access key>')
  [SETTINGS base_backup = File('<path>/<filename>') | Disk(...) | S3('<S3 endpoint>/<path>', '<Access key ID>', '<Secret access key>')]

the important part is

  DATABASE database_name [AS database_name_in_backup]

so for restore, you need to do the database_name in the service where the restore is performed AS the name of the database in the backup

@@ -88,8 +88,8 @@ SETTINGS base_backup = S3('https://testchbackups.s3.amazonaws.com/backups/<base-
### Restore from a backup {#restore-from-a-backup}

```sql
RESTORE DATABASE test_backups
AS test_backups_restored
Copy link
Contributor

Choose a reason for hiding this comment

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

this is restoring test_backups (backed up above) AS a new database, this doesnt seem incorrect to me

@gingerwizard
Copy link
Contributor

This seems counterintuitive, we need to test as the reference spec actually looks wrong to me.

@gingerwizard
Copy link
Contributor

so the syntax isn't quite documented right, should be:

BACKUP|RESTORE
  TABLE [db.]table_name_in_backup [AS [db.]table_name_to_restore_to]

CREATE DATABASE test
USE test


CREATE TABLE test
(
    `x` String
)
ENGINE = MergeTree
ORDER BY tuple()


INSERT INTO test FORMAT Values


BACKUP DATABASE test TO S3('https://storage.googleapis.com/sql.clickhouse.com/backup/testy', 'GOOGN77RURDAYFDRHV5QPZ7B', '<HIDDEN>')

Query id: 93cd3d19-1df2-4af3-b8f2-afc5112fd897

   ┌─id───────────────────────────────────┬─status─────────┐
1. │ 57bc0809-bf12-4d47-806d-032bdef51d0d │ BACKUP_CREATED │
   └──────────────────────────────────────┴────────────────┘

1 row in set. Elapsed: 5.448 sec.




DROP DATABSE test;



RESTORE DATABASE test AS test_v2 FROM S3('https://storage.googleapis.com/sql.clickhouse.com/backup/testy', 'GOOGN77RURDAYFDRHV5QPZ7B', '<HIDDEN>')

Query id: d18fda77-9e93-4656-8e05-03970a95de47

   ┌─id───────────────────────────────────┬─status───┐
1. │ 739bde16-05bf-42b7-a6d5-84c8a14c3d70 │ RESTORED │
   └──────────────────────────────────────┴──────────┘

1 row in set. Elapsed: 7.773 sec.

play-eu-clickhouse-client.localdomain :) show databases

SHOW DATABASES

Query id: aa165b44-bab9-4a37-a448-0d60beb41a6c

   ┌─name───────────────┐
1. │ INFORMATION_SCHEMA │
2. │ default            │
3. │ information_schema │
4. │ system             │
5. │ test_v2            │
   └────────────────────┘

5 rows in set. Elapsed: 0.001 sec.


@gingerwizard
Copy link
Contributor

The issue is the syntax is correct for BACKUP but not for RESTORE where its inverted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants