此时的数据量
dba-docker :) show tables;SHOW TABLES
┌─name─┐
│ ch1 │ # 数据量 0
│ ch2 │ # 数据量 8990020*2=17980040
└──────┘ # ch3被drop
只使用 --schema 恢复ch3表的表结构
clickhouse-backup restore bk_3_tab -table caihao.ch3 --schema只有表结构,没数据
dba-docker :) select count(*) from ch3;SELECT count(*)
FROM ch3
┌─count()─┐
│ 0 │
└─────────┘
用 --data 恢复ch3表中数据
(注意,由于是ATTACH PART操作,如果执行2次的话,数据会翻倍)
clickhouse-backup restore bk_3_tab -table caihao.ch3 --data数据已导入
dba-docker :) select count(*) from ch3;SELECT count(*)
FROM ch3
┌─count()─┐
│ 8990020 │
└─────────┘
恢复其他表:
[root@dba-docker ~]# clickhouse-backup restore bk_3_tab2020/10/20 17:42:37 Create table \'caihao.ch1\'
2020/10/20 17:42:37 can\'t create table \'caihao.ch1\': code: 57, message: Table caihao.ch1 already exists.
由于要新建表,只能把表drop掉才能全库恢复。
直接 drop database,然后全库恢复
clickhouse-backup restore bk_3_tab验证后数据是全部恢复成功了
dba-docker :) show tables;SHOW TABLES
┌─name─┐
│ ch1 │
│ ch2 │
│ ch3 │
└──────┘
dba-docker :) select count(*) from ch1;
SELECT count(*)
FROM ch1
┌─count()─┐
│ 8990020 │
└─────────┘
# 加到每日备份任务中:
mkdir -p /data/clickhouse/scriptsvi /data/clickhouse/scripts/CH_Full_Backup.sh #!/bin/bash
BACKUP_NAME=CH_Full_Backup_$(date +%Y-%m-%dT%H-%M-%S)
/usr/bin/clickhouse-backup create $BACKUP_NAME
# /usr/bin/clickhouse-backup upload $BACKUP_NAME
原文链接:https://mp.weixin.qq.com/s?src=11×tamp=1629098841&ver=3255&signature=FwALsxuhUf4-kQ9K-WOCyFrKbyZ6FZ2BZiSghswGuU6UBjRRQkL8kM99k3Tb*IQuh-Px2KtwmGISneW02qSt4I8-J*dVLX3bJF9Z8jK5W-GTfetzpUIizMO8XygA-Ph5&new=1