ClickHouse备份恢复⼯具:CLICKHOUSE-BACKUP 官⽅⽹址:
GitHub地址:
Limitations
ClickHouse above 1.1.54390 is supported
Only MergeTree family tables engines
Backup of 'Tiered storage' or storage_policy IS NOT SUPPORTED!
Maximum backup size on cloud storages is 5TB
Maximum number of parts on AWS S3 is 10,000 (increase part_size if your database is more than 1TB)
⼀、下载安装
wget github/AlexAkulov/clickhouse-backup/releases/download/v0.5.2/
tar -xf
cd clickhouse-backup/
sudo cp clickhouse-backup /usr/local/bin
clickhouse-backup -v
当前版本
可以直接下载rpm或者tar包
⼆、配置clickhouse-backup
最⼩配置
$ cat /etc/l
general:
remote_storage: none
⽣成全配置
clickhouse-backup default-config
查看clickhouse-backup帮助
$ clickhouse-backup help
NAME:
clickhouse-backup - Tool for easy backup of ClickHouse with cloud support
.
..
COMMANDS:
tables          Print list of tables
create          Create new backup
upload          Upload backup to remote storage
list            Print list of backups
download        Download backup from remote storage
restore        Create schema and restore data from backup
delete          Delete specific backup
default-config  Print default config
freeze          Freeze tables
clean          Remove data in 'shadow' folder
server          Run API server
help, h        Shows a list of commands or help for one command
三、使⽤clickhouse-backup
1、查看可备份的表
$ clickhouse-backup tables
default.events
system.query_log    (ignored)
system.query_thread_log (ignored)
2、创建备份
$ sudo clickhouse-backup create
2020/07/06 20:13:02 Create backup '2020-07-06T20-13-02'
2020/07/06 20:13:02 Freeze `default`.`events`
2020/07/06 20:13:02 Skip `system`.`metric_log`
2020/07/06 20:13:02 Skip `system`.`query_log`
2020/07/06 20:13:02 Skip `system`.`query_thread_log`
2020/07/06 20:13:02 Skip `system`.`trace_log`
2020/07/06 20:13:02 Copy metadata
2020/07/06 20:13:02  Done.
2020/07/06 20:13:02 Move shadow
2020/07/06 20:13:02  Done.
3、查看备份
百度数据恢复
$ sudo clickhouse-backup list
Local backups:
- '2020-07-06T20-13-02' (created at 06-07-2020 20:13:02)
clickhouse-backup如上所述,在内部尽可能使⽤硬链接。备份存储在中/var/lib/clickhouse/backup/BACKUPNAME。
备份名称默认为时间戳,但是您可以选择使⽤–name标志指定备份名称。备份包含两个⽬录:⼀个“元数据”⽬录,
其中包含重新创建架构所需的DDL SQL语句;以及⼀个“影⼦”⽬录,其中包含作为ALTER TABLE ... FREEZE操作结果的数据。
4、数据还原
$ echo 'drop table events' | clickhouse-client
$ sudo clickhouse-backup restore 2020-07-06T20-13-02
2020/07/06 20:14:46 Create table `default`.`events`
2020/07/06 20:14:46 Prepare data for restoring `default`.`events`
2020/07/06 20:14:46 ALTER TABLE `default`.`events` ATTACH PART '202006_1_1_4'
2020/07/06 20:14:46 ALTER TABLE `default`.`events` ATTACH PART '202006_2_2_2'
2020/07/06 20:14:46 ALTER TABLE `default`.`events` ATTACH PART '202006_3_3_3'
2020/07/06 20:14:46 ALTER TABLE `default`.`events` ATTACH PART '202006_4_4_3'
2020/07/06 20:14:46 ALTER TABLE `default`.`events` ATTACH PART '202006_5_5_2'
2020/07/06 20:14:46 ALTER TABLE `default`.`events` ATTACH PART '202006_6_6_1'
该restore ⼦命令⾃动模式和数据恢复。如果只想还原架构,请使⽤可选--schema标志。或者,如果只
想还原数据(假设架构已存在),则可以使⽤该--data标志。后⼀种情况在还原到已经具有现有数据的服务器时特别有⽤。
5、备份指定表与数据库
另⼀个有⽤的功能是⽀持使⽤⼤多数命令(例如创建和还原)指定表模式。该--table参数允许您备份(或还原)特定表。你也可以使⽤⼀个正则表达式,例如,针对特定的数据库:--table=dbname.*。
6、备份到远程机器
略,查看官⽹
原创内容,转载请标明出处

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。