Backup and Restore in ClickHouse

**S3 specific settings**

|  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Setting Description Default value|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `use_same_s3_credentials_for_base_backup` Whether base backup to S3 should inherit credentials from the query. Only works with `S3`. |  |  |  | | --- | --- | --- | | `s3_storage_class` The storage class used for S3 backup. For example: `STANDARD`  | | | | | | | | |

**Azure specific settings**

|  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- |
| Setting Description Default value|  |  |  | | --- | --- | --- | | `azure_attempt_to_create_container` When using Azure Blob Storage, whether to attempt creating the specified container if it doesn't exist. `true` | | | | | |

## Administration and troubleshooting[​](#check-the-status-of-backups "Direct link to Administration and troubleshooting")

The backup command returns an `id` and `status`, and that `id` can be used to
get the status of the backup. This is very useful to check the progress of long
`ASYNC` backups. The example below shows a failure that happened when trying to
overwrite an existing backup file:

```
BACKUP TABLE helloworld.my_first_table TO Disk('backups', '1.zip') ASYNC
```

```
┌─id───────────────────────────────────┬─status──────────┐
│ 7678b0b3-f519-4e6e-811f-5a0781a4eb52 │ CREATING_BACKUP │
└──────────────────────────────────────┴─────────────────┘

1 row in set. Elapsed: 0.001 sec.
```

```
SELECT
*
FROM system.backups
WHERE id='7678b0b3-f519-4e6e-811f-5a0781a4eb52'
FORMAT Vertical
```

```
Row 1:
──────
id:                7678b0b3-f519-4e6e-811f-5a0781a4eb52
name:              Disk('backups', '1.zip')
#highlight-next-line
status:            BACKUP_FAILED
num_files:         0
uncompressed_size: 0
compressed_size:   0
#highlight-next-line
error:             Code: 598. DB::Exception: Backup Disk('backups', '1.zip') already exists. (BACKUP_ALREADY_EXISTS) (version 22.8.2.11 (official build))
start_time:        2022-08-30 09:21:46
end_time:          2022-08-30 09:21:46

1 row in set. Elapsed: 0.002 sec.
```

Along with the [`system.backups`](/docs/operations/system-tables/backups) table, all backup and restore operations are also tracked in the system log table
[`system.backup_log`](/docs/operations/system-tables/backup_log):

```
SELECT *
FROM system.backup_log
WHERE id = '7678b0b3-f519-4e6e-811f-5a0781a4eb52'
ORDER BY event_time_microseconds ASC
FORMAT Vertical
```

```
Row 1:
──────
event_date:              2023-08-18
event_time_microseconds: 2023-08-18 11:13:43.097414
id:                      7678b0b3-f519-4e6e-811f-5a0781a4eb52
name:                    Disk('backups', '1.zip')
status:                  CREATING_BACKUP
error:
start_time:              2023-08-18 11:13:43
end_time:                1970-01-01 03:00:00
num_files:               0
total_size:              0
num_entries:             0
uncompressed_size:       0
compressed_size:         0
files_read:              0
bytes_read:              0

Row 2:
──────
event_date:              2023-08-18
event_time_microseconds: 2023-08-18 11:13:43.174782
id:                      7678b0b3-f519-4e6e-811f-5a0781a4eb52
name:                    Disk('backups', '1.zip')
status:                  BACKUP_FAILED
#highlight-next-line
error:                   Code: 598. DB::Exception: Backup Disk('backups', '1.zip') already exists. (BACKUP_ALREADY_EXISTS) (version 23.8.1.1)
start_time:              2023-08-18 11:13:43
end_time:                2023-08-18 11:13:43
num_files:               0
total_size:              0
num_entries:             0
uncompressed_size:       0
compressed_size:         0
files_read:              0
bytes_read:              0

2 rows in set. Elapsed: 0.075 sec.
```

- [Introduction](#introduction)- [Backup types](#backup-types)- [Synchronous vs asynchronous backups](#synchronous-vs-asynchronous)- [Concurrent vs non-concurrent backups](#concurrent-vs-non-concurrent)- [Compressed vs uncompressed backups](#compressed-vs-uncompressed)- [Using named collections](#using-named-collections)- [Backing up system, log or access management tables](#system-backups)- [General syntax](#syntax)
                - [Command summary](#command-summary)- [Settings](#settings)- [Administration and troubleshooting](#check-the-status-of-backups)

Was this page helpful?