Rclone 上传本地文件到 OSS

文章目录

一、下载安装

官网:https://rclone.org/

从预编译的二进制文件安装:

Windows:rclone-v1.64.2-windows-amd64.zip

Linux:rclone-current-linux-amd64.zip

获取并解包:

shell 复制代码
curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
cd rclone-*-linux-amd64

复制二进制文件:

shell 复制代码
sudo cp rclone /usr/bin/
sudo chown root:root /usr/bin/rclone
sudo chmod 755 /usr/bin/rclone

直接执行 rclone version 可以查看到版本号即安装成功。

二、配置

配置可以直接添加配置文件的方式或者通过进入交互式配置会话命令一步步的完成配置。

默认配置完成的后配置文件都保存在:/root/.config/rclone/rclone.conf 目录下。

Rclone 的配置向导相当友好,可以通过命令 Rclone config 进行配置,输入 n 新建:

shell 复制代码
[root@localhost rclone-v1.64.2-linux-amd64]# rclone config

No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n

Enter name for new remote.
name> osstest

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, ArvanCloud, Ceph, China Mobile, Cloudflare, GCS, DigitalOcean, Dreamhost, Huawei OBS, IBM COS, IDrive e2
, IONOS Cloud, Leviia, Liara, Lyve Cloud, Minio, Netease, Petabox, RackCorp, Scaleway, SeaweedFS, StackPath, Storj, Synology, 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 / Mega
   \ (mega)
30 / Microsoft Azure Blob Storage
   \ (azureblob)
31 / Microsoft OneDrive
   \ (onedrive)
32 / OpenDrive
   \ (opendrive)
33 / OpenStack Swift (Rackspace Cloud Files, Blomp Cloud Storage, Memset Memstore, OVH)
   \ (swift)
34 / Oracle Cloud Infrastructure Object Storage
   \ (oracleobjectstorage)
35 / Pcloud
   \ (pcloud)
36 / PikPak
   \ (pikpak)
37 / Proton Drive
   \ (protondrive)
38 / Put.io
   \ (putio)
39 / QingCloud Object Storage
   \ (qingstor)
40 / Quatrix by Maytech
   \ (quatrix)
41 / SMB / CIFS
   \ (smb)
42 / SSH/SFTP
   \ (sftp)
43 / Sia Decentralized Cloud
   \ (sia)
44 / Storj Decentralized Cloud Storage
   \ (storj)
45 / Sugarsync
   \ (sugarsync)
46 / Transparently chunk/split large files
   \ (chunker)
47 / Union merges the contents of several upstream fs
   \ (union)
48 / Uptobox
   \ (uptobox)
49 / WebDAV
   \ (webdav)
50 / Yandex Disk
   \ (yandex)
51 / Zoho
   \ (zoho)
52 / premiumize.me
   \ (premiumizeme)
53 / seafile
   \ (seafile)
Storage> 5

Option provider.
Choose your S3 provider.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 1 / Amazon Web Services (AWS) S3
   \ (AWS)
 2 / Alibaba Cloud Object Storage System (OSS) formerly Aliyun
   \ (Alibaba)
 3 / Arvan Cloud Object Storage (AOS)
   \ (ArvanCloud)
 4 / Ceph Object Storage
   \ (Ceph)
 5 / China Mobile Ecloud Elastic Object Storage (EOS)
   \ (ChinaMobile)
 6 / Cloudflare R2 Storage
   \ (Cloudflare)
 7 / DigitalOcean Spaces
   \ (DigitalOcean)
 8 / Dreamhost DreamObjects
   \ (Dreamhost)
 9 / Google Cloud Storage
   \ (GCS)
10 / Huawei Object Storage Service
   \ (HuaweiOBS)
11 / IBM COS S3
   \ (IBMCOS)
12 / IDrive e2
   \ (IDrive)
13 / IONOS Cloud
   \ (IONOS)
14 / Seagate Lyve Cloud
   \ (LyveCloud)
15 / Leviia Object Storage
   \ (Leviia)
16 / Liara Object Storage
   \ (Liara)
17 / Minio Object Storage
   \ (Minio)
18 / Netease Object Storage (NOS)
   \ (Netease)
19 / Petabox Object Storage
   \ (Petabox)
20 / RackCorp Object Storage
   \ (RackCorp)
21 / Scaleway Object Storage
   \ (Scaleway)
22 / SeaweedFS S3
   \ (SeaweedFS)
23 / StackPath Object Storage
   \ (StackPath)
24 / Storj (S3 Compatible Gateway)
   \ (Storj)
25 / Synology C2 Object Storage
   \ (Synology)
26 / Tencent Cloud Object Storage (COS)
   \ (TencentCOS)
27 / Wasabi Object Storage
   \ (Wasabi)
28 / Qiniu Object Storage (Kodo)
   \ (Qiniu)
29 / Any other S3 compatible provider
   \ (Other)
provider> 2

Option env_auth.
Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars).
Only applies if access_key_id and secret_access_key is blank.
Choose a number from below, or type in your own boolean value (true or false).
Press Enter for the default (false).
 1 / Enter AWS credentials in the next step.
   \ (false)
 2 / Get AWS credentials from the environment (env vars or IAM).
   \ (true)
env_auth> 1

Option access_key_id.
AWS Access Key ID.
Leave blank for anonymous access or runtime credentials.
Enter a value. Press Enter to leave empty.
access_key_id> LTAI5t9my6nXvthk2WDvycsL

Option secret_access_key.
AWS Secret Access Key (password).
Leave blank for anonymous access or runtime credentials.
Enter a value. Press Enter to leave empty.
secret_access_key> CnmbEVIfmBLiJidWPAqduTGUXeyV1h

Option endpoint.
Endpoint for OSS API.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 1 / Global Accelerate
   \ (oss-accelerate.aliyuncs.com)
 2 / Global Accelerate (outside mainland China)
   \ (oss-accelerate-overseas.aliyuncs.com)
 3 / East China 1 (Hangzhou)
   \ (oss-cn-hangzhou.aliyuncs.com)
 4 / East China 2 (Shanghai)
   \ (oss-cn-shanghai.aliyuncs.com)
 5 / North China 1 (Qingdao)
   \ (oss-cn-qingdao.aliyuncs.com)
 6 / North China 2 (Beijing)
   \ (oss-cn-beijing.aliyuncs.com)
 7 / North China 3 (Zhangjiakou)
   \ (oss-cn-zhangjiakou.aliyuncs.com)
 8 / North China 5 (Hohhot)
   \ (oss-cn-huhehaote.aliyuncs.com)
 9 / North China 6 (Ulanqab)
   \ (oss-cn-wulanchabu.aliyuncs.com)
10 / South China 1 (Shenzhen)
   \ (oss-cn-shenzhen.aliyuncs.com)
11 / South China 2 (Heyuan)
   \ (oss-cn-heyuan.aliyuncs.com)
12 / South China 3 (Guangzhou)
   \ (oss-cn-guangzhou.aliyuncs.com)
13 / West China 1 (Chengdu)
   \ (oss-cn-chengdu.aliyuncs.com)
14 / Hong Kong (Hong Kong)
   \ (oss-cn-hongkong.aliyuncs.com)
15 / US West 1 (Silicon Valley)
   \ (oss-us-west-1.aliyuncs.com)
16 / US East 1 (Virginia)
   \ (oss-us-east-1.aliyuncs.com)
17 / Southeast Asia Southeast 1 (Singapore)
   \ (oss-ap-southeast-1.aliyuncs.com)
18 / Asia Pacific Southeast 2 (Sydney)
   \ (oss-ap-southeast-2.aliyuncs.com)
19 / Southeast Asia Southeast 3 (Kuala Lumpur)
   \ (oss-ap-southeast-3.aliyuncs.com)
20 / Asia Pacific Southeast 5 (Jakarta)
   \ (oss-ap-southeast-5.aliyuncs.com)
21 / Asia Pacific Northeast 1 (Japan)
   \ (oss-ap-northeast-1.aliyuncs.com)
22 / Asia Pacific South 1 (Mumbai)
   \ (oss-ap-south-1.aliyuncs.com)
23 / Central Europe 1 (Frankfurt)
   \ (oss-eu-central-1.aliyuncs.com)
24 / West Europe (London)
   \ (oss-eu-west-1.aliyuncs.com)
25 / Middle East 1 (Dubai)
   \ (oss-me-east-1.aliyuncs.com)
endpoint> 5

Option acl.
Canned ACL used when creating buckets and storing or copying objects.
This ACL is used for creating objects and if bucket_acl isn't set, for creating buckets too.
For more info visit https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
Note that this ACL is applied when server-side copying objects as S3
doesn't copy the ACL from the source but rather writes a fresh one.
If the acl is an empty string then no X-Amz-Acl: header is added and
the default (private) will be used.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
   / 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)
   / Object owner gets FULL_CONTROL.
 5 | Bucket owner gets READ access.
   | If you specify this canned ACL when creating a bucket, Amazon S3 ignores it.
   \ (bucket-owner-read)
   / Both the object owner and the bucket owner get FULL_CONTROL over the object.
 6 | If you specify this canned ACL when creating a bucket, Amazon S3 ignores it.
   \ (bucket-owner-full-control)
acl> 1

Option storage_class.
The storage class to use when storing new objects in OSS.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 1 / Default
   \ ()
 2 / Standard storage class
   \ (STANDARD)
 3 / Archive storage mode
   \ (GLACIER)
 4 / Infrequent access storage mode
   \ (STANDARD_IA)
storage_class> 1

Edit advanced config?
y) Yes
n) No (default)
y/n> n

Configuration complete.
Options:
- type: s3
- provider: Alibaba
- access_key_id: XXXXX
- secret_access_key: XXXXX
- endpoint: XXXXX
- acl: private
Keep this "osstest" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y

Current remotes:

Name                 Type
====                 ====
osstest              s3

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q
[root@localhost rclone-v1.64.2-linux-amd64]# vim /root/.config/rclone/rclone.conf 
[osstest]
type = s3
provider = Alibaba
access_key_id = XXXXX
secret_access_key = XXXXX
endpoint = XXXXX
acl = private

注:上面是通过 Amazon S3 协议挂载的 OSS,符合亚马逊 S3 标准的存储提供商,包括 AWS、阿里巴巴、Ceph、中国移动、Cloudflare、ArvanCloud、DigitalOcean、Dreamhost、华为OBS、IBM COS、IDrive e2、IONOS Cloud、Liara、Lyve Cloud、Minio、网易、RackCorp、Scaleway、SeaweedFS、StackPath、Storj、腾讯COS、Qiniu 和 Wasabi。

shell 复制代码
# Linux
[root@localhost xiaoqingtest]# rclone copy -P data/heheda-2023-11-10_18-0.log osstest:/heheda/xiaoqiangtest/ --transfers=16
Transferred:   	  316.715 MiB / 316.715 MiB, 100%, 18.607 MiB/s, ETA 0s
Transferred:            1 / 1, 100%
Elapsed time:        18.0s

# Windos
D:\Application\Rclone\rclone-v1.64.2-windows-amd64>rclone copy -P D:\test.txt osstest:/heheda/xiaoqiangtest/ --transfers=16
Transferred:             11 B / 11 B, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.3s
相关推荐
宝子向前冲2 天前
纯前端生成PDF(jsPDF)并下载保存或上传到OSS
前端·pdf·html2canvas·oss·jspdf
vvw&2 天前
使用Ubuntu快速部署MinIO对象存储
linux·运维·服务器·ubuntu·minio·cos·oss
soso196819 天前
AWS S3迁移到阿里云OSS实践
阿里云·云计算·aws·oss·迁移
碎像1 个月前
阿里云对象存储OSS 速学
java·阿里云·oss
lihongbao802 个月前
rclone实现数据迁移、备份还原
minio·rclone
ps酷教程2 个月前
阿里云OSS文件存储
oss
记得开心一点嘛3 个月前
使用Redis来实现JWT令牌主动失效机制
数据库·redis·缓存·oss
luck_lin3 个月前
centos安装rclone挂载alist
centos·rclone·webdav
代码星辰3 个月前
功能实现——通过阿里云 OSS 实现文件管理
阿里云·文件上传·oss·文件下载
记得开心一点嘛3 个月前
阿里云OSS对象存储的项目实战操作
spring boot·spring·阿里云·oss