Skip to main content
This article covers backing up or restoring backups to/from an S3 bucket via an S3 endpoint.

Syntax

See “command summary” for more details of each command.

Usage example

Incremental backup to an S3 endpoint

In this example, we will create a backup to an S3 endpoint and then restore from it again.
For an explanation of the differences between a full backup and an incremental backup, see “Backup types”
You will need the following information to use this method:
Creating an S3 bucket is covered in section “use S3 Object Storage as a ClickHouse disk”
The destination for a backup is specified as:

1

Setup

Create the following database and table and insert some random data into it:
2

Create a base backup

Incremental backups require a base backup to start from. The first parameter of the S3 destination is the S3 endpoint followed by the directory within the bucket to use for this backup. In this example the directory is named my_backup.Run the following command to create the base backup:
3

Add more data

Incremental backups are populated with the difference between the base backup and the current content of the table being backed up. Add more data before taking the incremental backup:
4

Take an incremental backup

This backup command is similar to the base backup, but adds SETTINGS base_backup and the location of the base backup. Note that the destination for the incremental backup isn’t the same directory as the base, it is the same endpoint with a different target directory within the bucket. The base backup is in my_backup, and the incremental will be written to my_incremental:
5

Restore from the incremental backup

This command restores the incremental backup into a new table, test_table_restored.
Note that when an incremental backup is restored, the base backup is also included. Specify only the incremental backup when restoring:
6

Verify the count

There were two inserts into the original table data, one with 1,000 rows and one with 100 rows, for a total of 1,100. Verify that the restored table has 1,100 rows:
7

Verify the content

This compares the content of the original table, test_table with the restored table test_table_restored:
Last modified on June 12, 2026