Backup/restore 使用示例

Backup/restore

内容:

backup&restore使用示例

环境:

mysql -h xxxx -Pxxx -uroot

总体流程:

  • 先创建云端仓库用于备份与恢复(新老集群都要创建云端仓库)
  • REPOSITORY名字要相同,BROKER Name要查看集群的broker名称);
  • 在老集群准备好需要进行迁移备份的表,Backup到云端仓库;
  • 再从云端仓库Restore到新集群。

建立云端仓库

CREATE REPOSITORY `RepositoryName`
WITH BROKER `broker1`
ON LOCATION "ossn://xxxx" 
PROPERTIES
( 
 "fs.oss.accessKeyId" = "xxxx",
 "fs.oss.accessKeySecret" = "xxxx",
 "fs.oss.endpoint" = "xxxx"
);

ERROR 1064 (HY000): Failed to create repository: failed to list remote path: ossn://starrocks-data/test/__palo_repository_RepositoryName/__repo_info. msg: invalid path. scheme is not supported, cause by: null, broker: broker1[TNetworkAddress(hostname:172.26.92.139, port:8007)]

sh

路径错误。。。修改 ON LOCATION 为正确地址

CREATE REPOSITORY `RepositoryName`
WITH BROKER `broker1`
ON LOCATION "oss://xxxx" 
PROPERTIES
( 
 "fs.oss.accessKeyId" = "xxxx",
 "fs.oss.accessKeySecret" = "xxxx",
 "fs.oss.endpoint" = "xxxx"
);

备份数据到云端仓库

BACKUP SNAPSHOT qcy.t

estsnapshot

TO RepositoryName

ON ( CM_SUBSCRIBER ,OM_OFFERING_ATTR,test)

PROPERTIES ("type" = "full");

SHOW BACKUP FROM qcy\G;查看备份状态

在云端可以看到已经备份成功。

恢复云端数据到集群

Drop table test

SHOW SNAPSHOT ON RepositoryName 查看snapshotname和timestamp

RESTORE SNAPSHOT qcy.testsnapshot
FROM RepositoryName

ON ( test)

PROPERTIES

(

“backup_timestamp”=“2021-09-02-16-53-06-316”,

“replication_num” = “1”

);

show restore from qcy\G;

可以看到数据已经恢复成功了。