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 │
   └──────────────────────────────────────┴────────────────┘
相关推荐
洛小豆17 小时前
在Java中,Integer.parseInt和Integer.valueOf有什么区别
java·后端·面试
前端小张同学17 小时前
服务器上如何搭建jenkins 服务CI/CD😎😎
java·后端
ytadpole17 小时前
Spring Cloud Gateway:一次不规范 URL 引发的路由转发404问题排查
java·后端
华仔啊17 小时前
基于 RuoYi-Vue 轻松实现单用户登录功能,亲测有效
java·vue.js·后端
程序员鱼皮18 小时前
刚刚 Java 25 炸裂发布!让 Java 再次伟大
java·javascript·计算机·程序员·编程·开发·代码
浮游本尊18 小时前
Java学习第21天 - 微服务架构设计
java
渣哥18 小时前
Java CyclicBarrier 详解:原理、使用方式与应用场景
java
杨杨杨大侠18 小时前
打开 JVM 黑匣子——走进 Java 字节码(一)
java·jvm·agent
SimonKing18 小时前
接口调用总失败?试试Spring官方重试框架Spring-Retry
java·后端·程序员