RESTORE
RESTORE
Description
This statement is used to restore the back backed up by BACKUP command to specified database.
This command is an asynchronous operation. After successful submission, the progress should be viewed by SHOW RESTORE command.
Only OLAP-type tables can be restored.
RESTORE SNAPSHOT [db_name.]snapshot_name
FROM `repository_name`
ON (
`table_name` [PARTITION (`p1`, ...)] [AS `tbl_alias`],
...
)
PROPERTIES ("key"="value", ...);
snapshot_name
:the Snapshot name that can be viewed by SHOW SNAPSHOT command.repository_name
:repository name.-
ON
ON
clause specifies the tables and partitions in the snapshot that need to be backed up. In which the table name and partition name must be the names in the backup snapshot, andtbl_alias
can specify aliases for the table. The final recovered table will adopt this alias. Partition name cannot be modified. If no partition is specified, all partitions of the table are restored by default. The specified table and partition must already exist in the respository backup. -
PROPERTIES
:Specify properties related to recovery operationbackup_timestamp
:Specify which time version of the corresponding backup snapshot to restore; required. This information can be obtained by SHOW SNAPSHOT command.replication_num
:Specify the number of replication of the recovered table or partition, which is 3 by default. Specify the number of replication of the recovered table or partition. At the same time, the number of Compute Node nodes must be greater than or equal to the specified number of replication.timeout
:Task timeout period, default to one day, in seconds.
Example
-
Back up the table backup_tbl in snapshot_1 from example_repo to the database example_db1 with the time version of "2020-05-04-16-45-08". Restore to 1 replication:
RESTORE SNAPSHOT example_db1.`snapshot_1` FROM `example_repo` ON ( `backup_tbl` ) PROPERTIES ( "backup_timestamp"="2020-05-04-16-45-08", "replication_num" = "1" );
-
Partition P1 and p2 of backup_tbl in backup snapshot_2 and backup_tbl2 are restored from example_repo to database example_db1, and renamed as new_tbl with the time version of "2020-05-04-17-11-01". The default recovery is 3 replications:
RESTORE SNAPSHOT example_db1.`snapshot_2` FROM `example_repo` ON ( `backup_tbl` PARTITION (`p1`, `p2`), `backup_tbl2` AS `new_tbl` ) PROPERTIES ( "backup_timestamp"="202-05-04-17-11-01" );
Keywords
RESTORE, SNAPSHOT
Best Practices
- There can only be one ongoing recovery operation under the same database.
- The table backed up in the respository can be restored to replace the existing table with the same name in the database, but the table structure of the two tables must be completely consistent. Table structure includes: Table names, columns, partitions, materialized views, and so on.
- When a partial partition of the recovery table is specified, the system checks whether the partition range can match.
-
Efficiency of recovery operation:
When the cluster size is the same, the time consumption of recovery operation is basically equal to that of backup operation. To speed up the recovery operation, user can restore only one replication by setting
replication_num
and then adjust the number of replications through ALTER TABLE PROPERTY to make up the number of replications.