Rclone

Rclone

Rclone

rclone可以方便对共享存储进行读取,挂载等操作,使用简单

安装

debian

1
sudo apt-get install rclone

centos

1
sudo yum -y install rclone fuse

配置文件

linux位于

1
~/.config/rclone/rclone.conf

可以通过rclone config进行交互操作

rclone多个盘cygwin下会有问题

conf放到默认的.config/rclone/rclone.conf即可

rclone如何保护rclone.conf

https://rclone.org/docs/#configuration-encryption

建议方法 rclone config )s 输入对应的密码即可

然后再检查

1
2
3
4
5
➜  ~ cat .config/rclone/rclone.conf   
# Encrypted rclone configuration File

RCLONE_ENCRYPT_V0:
t+YBM+N7XrY9g7KzdEhgSTWJCMk6A1K5xgm+gc+1JwG3ffD8jukORq4Q6L/tjSIepYvM81xQfykmu9rDsoQoNpdXqcS2bqF3VsPbeIHcoRi/v3bNlUfv57mGK4/TMl7S8fIjjxA9biSiy1HKJZK+z+IH9hl4NvQnVJm+qgDBD/Z5/lwsaA2S+P1Nd8vsj8RAEGT5KAjDpUQZHKJwbGR2opuoaCutcD1nCTNPq+V7yGsEH3TmjX50XrJc8NZynowJpt5n1s1ZomgUbErdv3k6JhXnz0ociWktWsfnMm27sN4I3SA87XM6eXZCTdfAxC3ZAaw5vhZHLRZm+OdkmvO811jNQ/pBKwLNIy8Ro399rJh/++CFpcu3aoMzyqPLuyyxCDceb1fzgcaLITfvhus/WAwpV1dUj+6B8owmTo54vcTM4l8XJcz5C8rW+oOtVFuESFEKiZgE61goAxRciSJO5UJM+PkE6Sg9IMnPy033W7qgWkZb2wGjEbv9UbNPhfQy2bbzCJhOW8c5vcwvD9HBiE+MMhtI9mH6AyaWjT/GkEOsITfmtmGuIz519jV6pTFmGI2AIXjjrbFhJ5/4qYqP9blkLAVlSARwYCCZYsHwEaSSyUFgYHEKiR99VxcQ+A+G96MiJkOwcVWw+IuaD6ggEQg1l6g/WOSf1byahywNuW+zZKc+geVUqyayjAJ9CMcfFPRJexNuPsHBV9iyStzBMTW061hC2QCkJJqRxrxghmfwTdvf6BzXnbf3FvOdPrpXpxkO3b0mAVQIi+O6NNecQij1U4zaBpStvEuFhSQU6597GoSgbadvPozM7ZVw3VZ+4s7Kym/F7ik5G7xpDTzaq0BAJUOEoY2hcbIsIyaOjLicEw640XvfB6nNvpfSrMAUIsH+3B2/guaog0YY+OPkIewe73czU0F2yK4ye2zAQEI0wJYQ2pzYS2IMpRMEHNdcHtA2Yl/vv42Ge3uVUMD7BkQHzQan8n0y8B0zwBDMqTl+Lvzc9MsZEsZRoTjozLddfMNNNFDSF%

后续调用的时候

1
2
3
➜  ~ rclone ls my_storage:publish --verbose
Enter configuration password:
password:

rclone mount

1
rclone mount --rc --daemon rclone_section:s3_position /xxx --allow-non-empty --rc-addr=":5575"

如果不同端口加–rc-addr就好了 rclone refresh

1
rclone rc vfs/refresh recursive=true

Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH

1
yum -y install fuse

mount以后其他人或者nginx无法读取

1
rclone mount --allow-other

s3cmd 配置滚动

from https://clouddocs.web.cern.ch/object_store/s3cmd.html

1
s3cmd expire s3://dvanders-test --expiry-days 2

rclone通过proxy挂载

1
https_proxy=xxxx rclone mount

rclone gcp报错2024/02/22 02:57:10 Failed to copy: googleapi: Error 400: Cannot insert legacy ACL for an object when uniform bucket-level access is enabled. Read more at https://cloud.google.com/storage/docs/uniform-bucket-level-access, invalid

增加参数–gcs-bucket-policy-only

1
root@linux:~# rclone --gcs-bucket-policy-only copy test.txt dalas:battle-test/test/

开机自启动

配置成service并且设置成enable

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[Unit]
Description=Rclone Mount Service
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/rclone mount remote:path /path/to/mount/point --config=/etc/rclone.conf --allow-other
ExecStop=/usr/bin/fusermount -u /path/to/mount/point
Restart=always

[Install]
WantedBy=multi-user.target

rclone找到小于30m的文件执行删除

注意删除是危险操作

1
rclone lsf --max-size 30M ai:wuduan-ai-robots/data/test5-30 | xargs -i echo rclone delete ai:wuduan-ai-robots/data/test5-30/{}

参考文档