跳过正文
RCLONE 【入门篇】
  1. 运维日记/

RCLONE 【入门篇】

·1583 字·4 分钟·
目录
rclone - 这篇文章属于一个选集。
§ 1: 本文

Rclone是一款支持超七十种云服务的命令行工具,提供高效的同步、加密与挂载功能,堪称云端存储领域的瑞士军刀。

RCLONE【入门篇】
#

描述信息:

  • 备份(并加密)文件至云存储 (Backup and encrypt files to cloud storage)
  • 从云存储恢复(并解密)文件 (Restore and decrypt files from cloud storage)
  • 将云端数据镜像到其他云服务或本地 (Mirror cloud data to other cloud services or locally)
  • 将数据迁移至云端,或在不同云存储供应商之间进行迁移 (Migrate data to the cloud, or between cloud storage vendors)
  • 将多个、加密、缓存或异构的云存储挂载为本地磁盘 (Mount multiple, encrypted, cached or diverse cloud storage as a disk)
  • 利用 lsf、ljson、size、ncdu 等工具分析并核算云存储中的数据 (Analyse and account for data held on cloud storage using lsf, ljson, size, ncdu)
  • 合并(Union)多个文件系统,将多个本地、云端文件系统统一呈现为一个 (Union file systems together to present multiple local and/or cloud file systems as one)

安装
#

1.脚本
#

sudo -v ; curl https://rclone.org/install.sh | sudo bash

2.软件包【推荐】
#

sudo apt install rclone

配置文档
#

官方文档: Rclone Configuration

一、对象存储
#

rclone config
  1. 创建一个远程配置
root@minikube:~# rclone config
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
  1. 输入 名称
Enter name for new remote.
name> qiniu
  1. 选择存储类型,国内对象存储选择 5 ,兼容AWS S3
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
 1 / 1Fichier
   \ (fichier)
 2 / Akamai NetStorage
   \ (netstorage)
 3 / Alias for an existing remote
   \ (alias)
 4 / Amazon Drive
   \ (amazon cloud drive)
 5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, China Mobile, Cloudflare, ArvanCloud, Digital Ocean, Dreamhost, Huawei OBS, IBM COS, IDrive e2, IONOS Cloud, Lyve Cloud, Minio, Netease, RackCorp, Scaleway, SeaweedFS, StackPath, Storj, Tencent COS, Qiniu and Wasabi
   \ (s3)
 6 / Backblaze B2
   \ (b2)
 7 / Better checksums for other remotes
   \ (hasher)
 8 / Box
   \ (box)
 9 / Cache a remote
   \ (cache)
10 / Citrix Sharefile
   \ (sharefile)
11 / Combine several remotes into one
   \ (combine)
12 / Compress a remote
   \ (compress)
13 / Dropbox
   \ (dropbox)
14 / Encrypt/Decrypt a remote
   \ (crypt)
15 / Enterprise File Fabric
   \ (filefabric)
16 / FTP
   \ (ftp)
17 / Google Cloud Storage (this is not Google Drive)
   \ (google cloud storage)
18 / Google Drive
   \ (drive)
19 / Google Photos
   \ (google photos)
20 / HTTP
   \ (http)
21 / Hadoop distributed file system
   \ (hdfs)
22 / HiDrive
   \ (hidrive)
23 / In memory object storage system.
   \ (memory)
24 / Internet Archive
   \ (internetarchive)
25 / Jottacloud
   \ (jottacloud)
26 / Koofr, Digi Storage and other Koofr-compatible storage providers
   \ (koofr)
27 / Local Disk
   \ (local)
28 / Mail.ru Cloud
   \ (mailru)
29 / Microsoft Azure Blob Storage
   \ (azureblob)
30 / Microsoft OneDrive
   \ (onedrive)
31 / OpenDrive
   \ (opendrive)
32 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ (swift)
33 / Pcloud
   \ (pcloud)
34 / Put.io
   \ (putio)
35 / SMB / CIFS
   \ (smb)
36 / SSH/SFTP
   \ (sftp)
37 / Sia Decentralized Cloud
   \ (sia)
38 / Sugarsync
   \ (sugarsync)
39 / Transparently chunk/split large files
   \ (chunker)
40 / Union merges the contents of several upstream fs
   \ (union)
41 / Uptobox
   \ (uptobox)
42 / WebDAV
   \ (webdav)
43 / Yandex Disk
   \ (yandex)
44 / Zoho
   \ (zoho)
45 / premiumize.me
   \ (premiumizeme)
46 / seafile
   \ (seafile)
Storage> 5
  1. 选择 提供商
 1 / Amazon Web Services (AWS) S3
   \ (AWS)
 2 / Alibaba Cloud Object Storage System (OSS) formerly Aliyun
   \ (Alibaba)
 3 / Ceph Object Storage
   \ (Ceph)
 4 / China Mobile Ecloud Elastic Object Storage (EOS)
   \ (ChinaMobile)
 5 / Cloudflare R2 Storage
   \ (Cloudflare)
 6 / Arvan Cloud Object Storage (AOS)
   \ (ArvanCloud)
 7 / Digital Ocean Spaces
   \ (DigitalOcean)
 8 / Dreamhost DreamObjects
   \ (Dreamhost)
 9 / Huawei Object Storage Service
   \ (HuaweiOBS)
10 / IBM COS S3
   \ (IBMCOS)
11 / IDrive e2
   \ (IDrive)
12 / IONOS Cloud
   \ (IONOS)
13 / Seagate Lyve Cloud
   \ (LyveCloud)
14 / Minio Object Storage
   \ (Minio)
15 / Netease Object Storage (NOS)
   \ (Netease)
16 / RackCorp Object Storage
   \ (RackCorp)
17 / Scaleway Object Storage
   \ (Scaleway)
18 / SeaweedFS S3
   \ (SeaweedFS)
19 / StackPath Object Storage
   \ (StackPath)
20 / Storj (S3 Compatible Gateway)
   \ (Storj)
21 / Tencent Cloud Object Storage (COS)
   \ (TencentCOS)
22 / Wasabi Object Storage
   \ (Wasabi)
23 / Qiniu Object Storage (Kodo)
   \ (Qiniu)
24 / Any other S3 compatible provider
   \ (Other)
provider> 23
  1. 选择 认证方式
 1 / Enter AWS credentials in the next step.
   \ (false)
 2 / Get AWS credentials from the environment (env vars or IAM).
   \ (true)
env_auth> 1
  1. 输入 Access Key ID
access_key_id>
  1. 输入 Secret Access Key
secret_access_key>
  1. 选择 区域
   / The default endpoint - a good choice if you are unsure.
 1 | East China Region 1.
   | Needs location constraint cn-east-1.
   \ (cn-east-1)
   / East China Region 2.
 2 | Needs location constraint cn-east-2.
   \ (cn-east-2)
   / North China Region 1.
 3 | Needs location constraint cn-north-1.
   \ (cn-north-1)
   / South China Region 1.
 4 | Needs location constraint cn-south-1.
   \ (cn-south-1)
   / North America Region.
 5 | Needs location constraint us-north-1.
   \ (us-north-1)
   / Southeast Asia Region 1.
 6 | Needs location constraint ap-southeast-1.
   \ (ap-southeast-1)
   / Northeast Asia Region 1.
 7 | Needs location constraint ap-northeast-1.
   \ (ap-northeast-1)
region> 1
  1. 选择 endpoint
 1 / East China Endpoint 1
   \ (s3-cn-east-1.qiniucs.com)
 2 / East China Endpoint 2
   \ (s3-cn-east-2.qiniucs.com)
 3 / North China Endpoint 1
   \ (s3-cn-north-1.qiniucs.com)
 4 / South China Endpoint 1
   \ (s3-cn-south-1.qiniucs.com)
 5 / North America Endpoint 1
   \ (s3-us-north-1.qiniucs.com)
 6 / Southeast Asia Endpoint 1
   \ (s3-ap-southeast-1.qiniucs.com)
 7 / Northeast Asia Endpoint 1
   \ (s3-ap-northeast-1.qiniucs.com)
endpoint> 1
  1. 选择 位置
 1 / East China Region 1
   \ (cn-east-1)
 2 / East China Region 2
   \ (cn-east-2)
 3 / North China Region 1
   \ (cn-north-1)
 4 / South China Region 1
   \ (cn-south-1)
 5 / North America Region 1
   \ (us-north-1)
 6 / Southeast Asia Region 1
   \ (ap-southeast-1)
 7 / Northeast Asia Region 1
   \ (ap-northeast-1)
location_constraint> 1
  1. 输入 Bucket 策略
   / Owner gets FULL_CONTROL.
 1 | No one else has access rights (default).
   \ (private)
   / Owner gets FULL_CONTROL.
 2 | The AllUsers group gets READ access.
   \ (public-read)
   / Owner gets FULL_CONTROL.
 3 | The AllUsers group gets READ and WRITE access.
   | Granting this on a bucket is generally not recommended.
   \ (public-read-write)
   / Owner gets FULL_CONTROL.
 4 | The AuthenticatedUsers group gets READ access.
   \ (authenticated-read)
bucket_acl> 1
  1. 其他选项 默认

  2. 配置文件

root@debian:~# ls -la .config/rclone/rclone.conf
-rw------- 1 root root 255 Jan  5 15:21 .config/rclone/rclone.conf

二、命令参数
#

查看帮助

man rclone
  1. 列出所有bucket
rclone lsd qiniu:

三、拷贝本地
#

  • transfers、checkers: 根据实际情况调整,默认不加可能提示错误: error reading source directory: ErrorOccurred: out of request quota
rclone copy qiniu:download /mnt/
--transfers=4
--checkers=8
--bwlimit 1M
--fast-list
--size-only
--s3-no-check-bucket
--progress

四、后台运行
#

  1. 创建服务
systemd-run --unit=rclone-download  rclone copy qiniu:download /data/download --bwlimit 15M --transfers 4 --checkers 8 --log-level INFO
  1. 查看状态
systemctl status rclone-download

journalctl -u rclone-download -f

结语
#

无论是在服务器间备份数据,还是将网盘挂载为本地磁盘,Rclone 凭借极高的兼容性与强大的命令行性能,成为了开发者和极客管理海量云端资源的终极解决方案,是提升数字化工作流效率的必备神技。


参考:

rclone - 这篇文章属于一个选集。
§ 1: 本文

相关文章


微信赞赏
微信赞赏
关注公众号
关注公众号
支付宝赞赏
支付宝赞赏