1.下载
下载地址
https://github.com/Altinity/clickhouse-backup
2.安装
[root@dc-biz-ck-192 soft]# rpm -ivh clickhouse-backup-2.4.35-1.x86_64.rpm
3.查看版本号
[root@dc-biz-ck-192 soft]# clickhouse-backup -v
Version: 2.4.35
Git Commit: 5e41c8be05849a4ce9e171fe2e11f55f9ece309b
Build Date: 2024-03-24
4.编辑配置文件
拷贝一份模版文件为配置文件
[root@dc-biz-ck-192 clickhouse-backup]# cd /etc/clickhouse-backup/
[root@dc-biz-ck-192 clickhouse-backup]# cp config.yml.example config.yml
修改配置文件config.yml
general: backups_to_keep_local: 3 clickhouse: username: default password: "123456"
5.查看可备份的表
[root@localhost clickhouse-backup]# clickhouse-backup tables
db_test.app_message_80 233.65MiB default
db_test.app_message_80_cp 0B default
6.创建备份
[root@localhost clickhouse-backup]#clickhouse-backup create
备份存储在中 $data_path/backup 下,备份名称默认为时间戳,可手动指定备份名称。例如:
[root@localhost clickhouse-backup]#clickhouse-backup create bak20240222
备份文件在clickhouse的data目录下
[root@dc-biz-ck-192 clickhouse-backup]# pwd
/etc/clickhouse-backup
[root@dc-biz-ck-192 click
[root@dc-biz-ck-192 clickhouse-backup]# ls -al /opt/clickhouse/data/backup/bak20240222
总用量 12
drwxr-x--- 3 clickhouse clickhouse 43 4月 22 16:39 .
drwxr-x--- 3 clickhouse clickhouse 25 4月 22 16:39 ..
drwxr-x--- 3 clickhouse clickhouse 20 4月 22 16:39 metadata
-rw-r----- 1 clickhouse clickhouse 8246 4月 22 16:39 metadata.json
7.查看备份文件
[root@localhost clickhouse-backup]# clickhouse-backup list
8.删除备份
clickhouse-backup delete local bak20240222
9.整理成备份脚本
[root@localhost scripts]# more backup_clickhouse.sh #!/bin/sh backup_date=`date "+%Y%m%d"` delete_date=`date +%Y%m%d -d "3 days ago"` /usr/local/bin/clickhouse-backup create bak${backup_date} /usr/local/bin/clickhouse-backup delete local bak${delete_date}
标签:RPM,dc,192,biz,root,backup,clickhouse From: https://www.cnblogs.com/hxlasky/p/18150983