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 │
   └──────────────────────────────────────┴────────────────┘
相关推荐
行云流水行云流水6 分钟前
数据库、数据仓库、数据中台、数据湖相关概念
数据库·数据仓库
John Song8 分钟前
Redis 集群批量删除key报错 CROSSSLOT Keys in request don‘t hash to the same slot
数据库·redis·哈希算法
写bug写bug13 分钟前
手把手教你使用JConsole
java·后端·程序员
异常君14 分钟前
Java 中 try-catch 的性能真相:全面分析与最佳实践
java·面试·代码规范
IvanCodes22 分钟前
七、Sqoop Job:简化与自动化数据迁移任务及免密执行
大数据·数据库·hadoop·sqoop
tonexuan32 分钟前
MySQL 8.0 绿色版安装和配置过程
数据库·mysql
JohnYan40 分钟前
工作笔记- 记一次MySQL数据移植表空间错误排除
数据库·后端·mysql
程序员清风1 小时前
阿里二面:Kafka 消费者消费消息慢(10 多分钟),会对 Kafka 有什么影响?
java·后端·面试
幼稚园的山代王1 小时前
Prompt Enginering(提示工程)先进技术
java·人工智能·ai·chatgpt·langchain·prompt
我最厉害。,。1 小时前
Windows权限提升篇&数据库篇&MYSQL&MSSQL&ORACLE&自动化项目
数据库·mysql·sqlserver