Clickhouse备份恢复_clickhouse-client方式backup命令之备份目录的设置

https://clickhouse.com/docs/en/operations/backup#command-summary

想要backup database dbname to Disk('diskname','backupfilename.zip')成功的话,需要符合3点

1、diskname需要在/etc/clickhouse-server/config.d/backup_disk.xml在<storage_configuration></storage_configuration>中存在

2、diskname需要在/etc/clickhouse-server/config.d/backup_disk.xml在<allowed_disk></allowed_disk>中存在

3、diskname需要在select name,path,type from system.disks结果集中存在

案例1、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>baks</allowed_disk>
        <allowed_path>/backups/345/</allowed_path>
    </backups>
</clickhouse>


CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''backups'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

CHDBDEV :) backup database lukestest1 to Disk('default','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

案例2、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>backups</allowed_disk>
        <allowed_path>/backups/123/</allowed_path>
    </backups>
</clickhouse>

CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024.zip');
   ┌─id───────────────────────────────────┬─status─────────┐
1. │ 803d8178-49fe-4f82-bf82-b70881496f0e │ BACKUP_CREATED │
   └──────────────────────────────────────┴────────────────┘

CHDBDEV :) backup database lukestest1 to Disk('default','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

案例3、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>backups</allowed_disk>
        <allowed_path>/backups/123/</allowed_path>
    </backups>
   <backups>
        <allowed_disk>default</allowed_disk>
        <allowed_path>/chdata/clickhouse/data/</allowed_path>
    </backups>
</clickhouse>

CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024_02.zip');
   ┌─id───────────────────────────────────┬─status─────────┐
1. │ 739aa691-5e94-4853-8f39-3bb422a749d6 │ BACKUP_CREATED │
   └──────────────────────────────────────┴────────────────┘

CHDBDEV :) backup database lukestest1 to Disk('default','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

案例4、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
        <disks>
            <default>
                <type>local</type>
                <path>/chdata/clickhouse/data/</path>
            </default>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>backups</allowed_disk>
        <allowed_path>/backups/123/</allowed_path>
    </backups>
   <backups>
        <allowed_disk>default</allowed_disk>
        <allowed_path>/chdata/clickhouse/data/</allowed_path>
    </backups>
</clickhouse>
CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024_03.zip');
   ┌─id───────────────────────────────────┬─status─────────┐
1. │ e5c9fe04-c24b-4760-b98e-dd5c366088a9 │ BACKUP_CREATED │
   └──────────────────────────────────────┴────────────────┘

CHDBDEV :) backup database lukestest1 to Disk('default','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

案例5、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
        <disks>
            <default2>
                <type>local</type>
                <path>/backups/345/</path>
            </default2>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>backups</allowed_disk>
        <allowed_path>/backups/123/</allowed_path>
    </backups>
   <backups>
        <allowed_disk>default2</allowed_disk>
        <allowed_path>/backups/345/</allowed_path>
    </backups>
</clickhouse>

CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024_04.zip');
   ┌─id───────────────────────────────────┬─status─────────┐
1. │ 72d58abc-c82d-4705-952f-c0e493662fd1 │ BACKUP_CREATED │
   └──────────────────────────────────────┴────────────────┘


CHDBDEV :) backup database lukestest1 to Disk('default2','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default2'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

案例6、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>backups</allowed_disk>
        <allowed_path>/backups/123/</allowed_path>
    </backups>
    <storage_configuration>
        <disks>
            <default2>
                <type>local</type>
                <path>/backups/345/</path>
            </default2>
        </disks>
    </storage_configuration>
   <backups>
        <allowed_disk>default2</allowed_disk>
        <allowed_path>/backups/345/</allowed_path>
    </backups>
</clickhouse>

CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('default2','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default2'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024_05.zip');
   ┌─id───────────────────────────────────┬─status─────────┐
1. │ b76f47d4-b6c9-4ff4-bff9-dcced56aa0b5 │ BACKUP_CREATED │
   └──────────────────────────────────────┴────────────────┘
相关推荐
齐 飞24 分钟前
MongoDB笔记01-概念与安装
前端·数据库·笔记·后端·mongodb
云空25 分钟前
《Python 与 SQLite:强大的数据库组合》
数据库·python·sqlite
暮毅29 分钟前
10.Node.js连接MongoDb
数据库·mongodb·node.js
wowocpp32 分钟前
ubuntu 22.04 server 格式化 磁盘 为 ext4 并 自动挂载 LTS
服务器·数据库·ubuntu
九圣残炎33 分钟前
【从零开始的LeetCode-算法】1456. 定长子串中元音的最大数目
java·算法·leetcode
wclass-zhengge35 分钟前
Netty篇(入门编程)
java·linux·服务器
成富1 小时前
文本转SQL(Text-to-SQL),场景介绍与 Spring AI 实现
数据库·人工智能·sql·spring·oracle
songqq271 小时前
SQL题:使用hive查询各类型专利top 10申请人,以及对应的专利申请数
数据库·sql
计算机学长felix1 小时前
基于SpringBoot的“校园交友网站”的设计与实现(源码+数据库+文档+PPT)
数据库·spring boot·毕业设计·交友
Re.不晚1 小时前
Java入门15——抽象类
java·开发语言·学习·算法·intellij-idea