基于rclone的跨云对象存储迁移
# 前言
图床之前存储在七牛云,现打算迁移到 Cloudflare R2,由于 R2 只支持 Amazon S3、Google Cloud Storage 的迁移。
# 最佳实践
- 安装 rclone:
scoop install rclone
- 在 rclone 官网 (opens new window)分别找到
Qiniu Cloud Object Storage (Kodo)
、Cloudflare R2
的 configQiniu Cloud Object Storage (Kodo)
:https://rclone.org/s3/#qiniuCloudflare R2
:https://rclone.org/s3/#cloudflare-r2
以七牛云为例,根据 rclone 文档的 config 执行:
rclone config
n/s/q> n
name> qiniu
Storage> s3
provider> Qiniu
env_auth> 1
access_key_id> AKIDxxxxxxxxxx
secret_access_key> xxxxxxxxxxx
...
笔记
cloudflare R2 的安全凭证需要在 R2 - 概述
页面,右侧的 管理 R2 API 令牌
添加
# 查看桶列表
rclone lsd qiniu:
rclone lsd r2:
# 查看桶里的文件列表
rclone ls r2:bucketName
# 复制s3:source_bucket所有文件到s3:destination_bucket
rclone copy s3:source_bucket s3:destination_bucket --progress
# 扩展:R2 防刷
# 缓存
将静态资源缓存到 cdn,减少源站访问
域名页面 -> 规则 -> 页面规则
- URL 填
static.example.com/*
- 添加设置:
缓存级别
–缓存所有内容
- 添加设置:
浏览器缓存 TTL
–8小时
- 添加设置:
边缘缓存 TTL
–一个月
# 防盗链
安全性 ->WAF,创建规则
(http.host eq "static.example.com" and not http.referer contains "blog.example.com" and http.referer ne "")
- 阻止
上次更新: 2024/03/13, 00:17:32