You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Examples.md
+100Lines changed: 100 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -847,3 +847,103 @@ The current implementation is simple and will improve in next releases.
847
847
- When the `watch` command starts, it calls the `create_remote+delete command` sequence to make a `full` backup
848
848
- Then it waits `watch-interval` time period and calls the `create_remote+delete` command sequence again. The type of
849
849
backup will be `full` if `full-interval` expired after last full backup created and `incremental` if not.
850
+
851
+
## How to restore a database or table to a different name
852
+
853
+
This example will restore a remote backup of database, and restore it to another differently named database. As well, the example will also demonstrate restoring a backed up table restored to a different table name. NOTE: this process will also work for local backups
854
+
855
+
Assumptions are that s3 credentials are already set up in a file called `s3.xml`:
### Backup and restore a database to a different database name
870
+
871
+
A remote database backup of the database `test` is created, first for an entire database with the backup name of `test`:
872
+
873
+
`clickhouse-backup create test`
874
+
875
+
Confirmation of the backup once completed:
876
+
877
+
```
878
+
clickhouse-backup list
879
+
880
+
test 21/04/2025 18:24:42 remote all:60.86MiB,data:60.70MiB,arch:60.85MiB,obj:2.50KiB,meta:0B,rbac:0B,conf:0B tar, regular
881
+
```
882
+
883
+
The user wants to restore this table as `testnew`, using the remote backup named `test`:
884
+
885
+
```
886
+
$ clickhouse-backup restore_remote --restore-database-mapping test:testnew test
887
+
```
888
+
889
+
Confirmation on Clickhouse:
890
+
891
+
```
892
+
:) show databases;
893
+
894
+
SHOW DATABASES
895
+
896
+
Query id: 5d42ae97-a521-4b60-8dc2-706b94416d78
897
+
898
+
┌─name───────────────┐
899
+
1. │ INFORMATION_SCHEMA │
900
+
2. │ default │
901
+
3. │ information_schema │
902
+
4. │ system │
903
+
5. │ test │
904
+
6. │ testnew │
905
+
└────────────────────┘
906
+
907
+
```
908
+
909
+
910
+
### Backup and restore a table to a different table name
911
+
912
+
In this example, a backup is made only of a table because in order to do this, only a table backup will work. In this example, the table name is `trips`, and is being restored using the name `trips2` to the same database the table-level backup was made, `test`,
Copy file name to clipboardExpand all lines: ReadMe.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -740,7 +740,7 @@ OPTIONS:
740
740
--environment-override value, --env value override any environment variable via CLI parameter
741
741
--table value, --tables value, -t value Restore only database and objects which matched with table name patterns, separated by comma, allow ? and * as wildcard
742
742
--restore-database-mapping value, -m value Define the rule to restore data. For the database not defined in this struct, the program will not deal with it.
743
-
--restore-table-mapping value, --tm value Define the rule to restore data. For the table not defined in this struct, the program will not deal with it.
743
+
--restore-table-mapping value, --tm value Define the rule to restore data. For the table not defined in this struct, the program will not deal with it. Note: only a table backup will work with this
744
744
--partitions partition_id Restore backup only for selected partition names, separated by comma
745
745
If PARTITION BY clause returns numeric not hashed values for partition_id field in system.parts table, then use --partitions=partition_id1,partition_id2 format
746
746
If PARTITION BY clause returns hashed string values, then use --partitions=('non_numeric_field_value_for_part1'),('non_numeric_field_value_for_part2') format
0 commit comments