图床迁移记录 Tecentcos到cloudfare r2
腾讯cos 存储倒不贵,但每月下行流量贵。算下来 顶每年服务器钱了....
Cloudfare r2免费流量够用
用的工具rclone
下载rclone后, ./rclone config 根据配置一层层配置好 Tecentcos 和 cloudfare r2 的配置,
配置完默认生成在 /Users/{username}/.config/rclone/rclone.conf
也可以直接基于下边配置自己的
config
(base) [rclone] cat rclone.conf
[tecent-cos]
type = s3
provider = TencentCOS
access_key_id = AxxxxxxxxFxxxxxv
secret_access_key = 8sdsadasdsdsadsadassad
endpoint = cos.ap-beijing.myqcloud.com
acl = public-read
storage_class = STANDARD
bucket_acl = public-read
[cfr2]
type = s3
provider = Cloudflare
access_key_id = ff23f2323fasfasfaa1fa
secret_access_key = fdsaf32f98hwa09f0jasofas8a
region = auto
endpoint = https://11sddkskfafsfffcbbc.r2.cloudflarestorage.com
bucket_acl = public-read-write%
tips
- r2 endpoint 就是 s3 API 默认带bucket name 。结尾删掉
- 配置admin权限,因为要同步文件夹 等
几个命令参考
./rclone copy tecent-cos:nexxxx36/images/2023/03/01/4478xxxxxxc5cee.png cfr2:blog/images/2023/03/01/
./rclone sync tecent-cos:nexxxxx6/images cfr2:blog/images
./clone purge cfr2:blog/images
./rclone copy tecent-cos:nexxxxx/blog cfr2:blog/blog -P
rclone ls remote:path # 列出了一个远程
rclone copy source:path destination:path --transfers 8
博客图片url替换内容
UPDATE t_topic SET `content` = REPLACE(content, 'oldxxx.maocaoying.com', 'cf.maocaoying.com');
UPDATE t_topic SET content = REPLACE(content, 'oldxxx.cos.ap-beijing.myqcloud.com', 'cf.maocaoying.com');
UPDATE t_topic
SET image_list = REPLACE(image_list, 'xxxxxg.myqcloud.com', 'cf.maocaoying.com');
其他表 用户图片 评论等