利用Rclone在S3存储间进行数据迁移

61 篇文章 0 订阅
12 篇文章 0 订阅

 本文记录了使用Rclone在S3存储间进行数据迁移的操作过程。

一、Rclone简介

1、Rclone程序

Rclone(“rsync for cloud storage”)是一个命令行程序,用于在不同的云存储提供商之间同步文件和目录。

官网地址

2、Rclone支持的云存储类型
1Fichier                                            Microsoft Azure Blob Storage      
Akamai Netstorage                                   Microsoft Azure Files Storage      
Alibaba Cloud (Aliyun) Object Storage System (OSS)  Microsoft OneDrive      
Amazon S3                                           Minio      
ArvanCloud Object Storage (AOS)                     Nextcloud      
Backblaze B2                                        OVH      
Box                                                 Blomp Cloud Storage      
Ceph                                                OpenDrive       
China Mobile Ecloud Elastic Object Storage (EOS)    OpenStack Swift      
Cloudflare R2                                       Oracle Cloud Storage      
Citrix ShareFile                                    Oracle Object Storage      
DigitalOcean Spaces                                 ownCloud      
Digi Storage                                        pCloud      
Dreamhost                                           Petabox      
Dropbox                                             PikPak      
Enterprise File Fabric                              premiumize.me      
Fastmail Files                                      put.io      
FTP                                                 Proton Drive      
Google Cloud Storage                                QingStor      
Google Drive                                        Qiniu Cloud Object Storage (Kodo)      
Google Photos                                       Quatrix      
HDFS (Hadoop Distributed Filesystem)                Rackspace Cloud Files      
HiDrive                                             RackCorp Object Storage      
HTTP                                                Scaleway      
Huawei Cloud Object Storage Service(OBS)            Seafile      
ImageKit                                            SeaweedFS      
Internet Archive                                    SFTP      
Jottacloud                                          SMB / CIFS      
IBM COS S3                                          StackPath      
IONOS Cloud                                         Storj      
Koofr                                               SugarSync      
Leviia Object Storage                               Synology C2 Object Storage      
Liara Object Storage                                Tencent Cloud Object Storage (COS)      
Linkbox                                             Uloz.to      
Linode Object Storage                               Wasabi      
Magalu Object Storage                               WebDAV      
Mail.ru Cloud                                       Yandex Disk      
Memset Memstore                                     Zoho WorkDrive      
Mega                                                The local filesystem      
Memory                                              
 3、操作系统及CPU支持

Rclone支持如下操作系统及介质平台

二、Rclone配置

Rclone支持交互式配置和直接编写配置文件两种方式

1、解压程序(以Linux-x86平台为例)
[root@localhost ~]# unzip rclone-v1.67.0-linux-amd64.zip 
Archive:  rclone-v1.67.0-linux-amd64.zip
   creating: rclone-v1.67.0-linux-amd64/
  inflating: rclone-v1.67.0-linux-amd64/rclone  
  inflating: rclone-v1.67.0-linux-amd64/README.html  
  inflating: rclone-v1.67.0-linux-amd64/git-log.txt  
  inflating: rclone-v1.67.0-linux-amd64/README.txt  
  inflating: rclone-v1.67.0-linux-amd64/rclone.1  
[root@localhost ~]# cd rclone-v1.67.0-linux-amd64/
[root@localhost rclone-v1.67.0-linux-amd64]# ll
total 67600
-rw-r--r-- 1 root root    89107 Jun 14 23:27 git-log.txt
-rwxr-xr-x 1 root root 61587608 Jun 14 23:30 rclone
-rw-r--r-- 1 root root  2504038 Jun 14 23:14 rclone.1
-rw-r--r-- 1 root root  2760746 Jun 14 23:14 README.html
-rw-r--r-- 1 root root  2267625 Jun 14 23:14 README.txt
[root@localhost rclone-v1.67.0-linux-amd64]# 
2、查看当前版本
[root@localhost rclone-v1.67.0-linux-amd64]# ./rclone version
rclone v1.67.0
- os/version: openeuler 22.03 (64 bit)
- os/kernel: 5.10.0-60.18.0.50.oe2203.x86_64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.22.4
- go/linking: static
- go/tags: none
3、交互式配置 
[root@localhost rclone-v1.67.0-linux-amd64]# ./rclone config
2024/07/16 14:01:59 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
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> mysource-old           

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 S3 Compliant Storage Providers including AWS, Alibaba, ArvanCloud, Ceph, ChinaMobile, Cloudflare, DigitalOcean, Dreamhost, GCS, HuaweiOBS, IBMCOS, IDrive, IONOS, LyveCloud, Leviia, Liara, Linode, Magalu, Minio, Netease, Petabox, RackCorp, Rclone, Scaleway, SeaweedFS, StackPath, Storj, Synology, TencentCOS, Wasabi, Qiniu and others
   \ (s3)
 5 / Backblaze B2
   \ (b2)
 6 / Better checksums for other remotes
   \ (hasher)
 7 / Box
   \ (box)
 8 / Cache a remote
   \ (cache)
 9 / Citrix Sharefile
   \ (sharefile)
10 / Combine several remotes into one
   \ (combine)
11 / Compress a remote
   \ (compress)
12 / Dropbox
   \ (dropbox)
13 / Encrypt/Decrypt a remote
   \ (crypt)
14 / Enterprise File Fabric
   \ (filefabric)
15 / FTP
   \ (ftp)
16 / Google Cloud Storage (this is not Google Drive)
   \ (google cloud storage)
17 / Google Drive
   \ (drive)
18 / Google Photos
   \ (google photos)
19 / HTTP
   \ (http)
20 / Hadoop distributed file system
   \ (hdfs)
21 / HiDrive
   \ (hidrive)
22 / ImageKit.io
   \ (imagekit)
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 / Linkbox
   \ (linkbox)
28 / Local Disk
   \ (local)
29 / Mail.ru Cloud
   \ (mailru)
30 / Mega
   \ (mega)
31 / Microsoft Azure Blob Storage
   \ (azureblob)
32 / Microsoft Azure Files
   \ (azurefiles)
33 / Microsoft OneDrive
   \ (onedrive)
34 / OpenDrive
   \ (opendrive)
35 / OpenStack Swift (Rackspace Cloud Files, Blomp Cloud Storage, Memset Memstore, OVH)
   \ (swift)
36 / Oracle Cloud Infrastructure Object Storage
   \ (oracleobjectstorage)
37 / Pcloud
   \ (pcloud)
38 / PikPak
   \ (pikpak)
39 / Proton Drive
   \ (protondrive)
40 / Put.io
   \ (putio)
41 / QingCloud Object Storage
   \ (qingstor)
42 / Quatrix by Maytech
   \ (quatrix)
43 / SMB / CIFS
   \ (smb)
44 / SSH/SFTP
   \ (sftp)
45 / Sia Decentralized Cloud
   \ (sia)
46 / Storj Decentralized Cloud Storage
   \ (storj)
47 / Sugarsync
   \ (sugarsync)
48 / Transparently chunk/split large files
   \ (chunker)
49 / Uloz.to
   \ (ulozto)
50 / Union merges the contents of several upstream fs
   \ (union)
51 / Uptobox
   \ (uptobox)
52 / WebDAV
   \ (webdav)
53 / Yandex Disk
   \ (yandex)
54 / Zoho
   \ (zoho)
55 / premiumize.me
   \ (premiumizeme)
56 / seafile
   \ (seafile)
Storage> 4

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 / Linode Object Storage
   \ (Linode)
18 / Magalu Object Storage
   \ (Magalu)
19 / Minio Object Storage
   \ (Minio)
20 / Netease Object Storage (NOS)
   \ (Netease)
21 / Petabox Object Storage
   \ (Petabox)
22 / RackCorp Object Storage
   \ (RackCorp)
23 / Rclone S3 Server
   \ (Rclone)
24 / Scaleway Object Storage
   \ (Scaleway)
25 / SeaweedFS S3
   \ (SeaweedFS)
26 / StackPath Object Storage
   \ (StackPath)
27 / Storj (S3 Compatible Gateway)
   \ (Storj)
28 / Synology C2 Object Storage
   \ (Synology)
29 / Tencent Cloud Object Storage (COS)
   \ (TencentCOS)
30 / Wasabi Object Storage
   \ (Wasabi)
31 / Qiniu Object Storage (Kodo)
   \ (Qiniu)
32 / Any other S3 compatible provider
   \ (Other)
provider> 4

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> 

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> WPDR4OJVAMV5ULEX1EGK

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> vfbPHhM0wXxDt1HcB25WdJp5kO2vLHFSqdI61rar

Option region.
Region to connect to.
Leave blank if you are using an S3 clone and you don't have a region.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
   / Use this if unsure.
 1 | Will use v4 signatures and an empty region.
   \ ()
   / Use this only if v4 signatures don't work.
 2 | E.g. pre Jewel/v10 CEPH.
   \ (other-v2-signature)
region> 

Option endpoint.
Endpoint for S3 API.
Required when using an S3 clone.
Enter a value. Press Enter to leave empty.
endpoint> 192.168.188.14:8080

Option location_constraint.
Location constraint - must be set to match the Region.
Leave blank if not sure. Used when creating buckets only.
Enter a value. Press Enter to leave empty.
location_constraint> 

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> 

Option server_side_encryption.
The server-side encryption algorithm used when storing this object in S3.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 1 / None
   \ ()
 2 / AES256
   \ (AES256)
 3 / aws:kms
   \ (aws:kms)
server_side_encryption> 

Option sse_kms_key_id.
If using KMS ID you must provide the ARN of Key.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 1 / None
   \ ()
 2 / arn:aws:kms:*
   \ (arn:aws:kms:us-east-1:*)
sse_kms_key_id> 

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

Configuration complete.
Options:
- type: s3
- provider: Ceph
- access_key_id: WPDR4OJVAMV5ULEX1EGK
- secret_access_key: vfbPHhM0wXxDt1HcB25WdJp5kO2vLHFSqdI61rar
- endpoint: 192.168.188.14:8080
Keep this "mysource-old" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y

Current remotes:

Name                 Type
====                 ====
mysource-old            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.67.0-linux-amd64]#

上述步骤简解: 

  • n/s/q> n----------------------------------------------------------------------------------n,新建一个远端配置
  • name> mysource-old ----------------------------------------------------------------输入自定义远端名
  • Storage> 4------------------------------------------------------------------------------选4,存储类型为s3
  • provider> 4------------------------------------------------------------------------------选4,对象存储
  • env_auth> ------------------------------------------------------------------------------用key认证直接回车
  • access_key_id> WPDR4OJVAMV5ULEX1EGK------------------------------输入access_key
  • secret_access_key> vfbPHhM0wXxDt1HcB25WdJp5kO2vLHFSqdI61rar----------------输入secret_access_key
  • region> ----------------------------------------------------------------------------------直接回车
  • endpoint> 192.168.188.14:8080---------------------------------------------------输入对象存储网关url
  • location_constraint> ------------------------------------------------------------------直接回车
  • acl>  ---------------------------------------------------------------------------------------直接回车
  • server_side_encryption> --------------------------------------------------------------直接回车
  • sse_kms_key_id> ----------------------------------------------------------------------直接回车
  • y/n> n-------------------------------------------------------------------------------------n,不配高级配置
  • y/e/d> y-----------------------------------------------------------------------------------y,确认配置
  • e/n/d/r/c/s/q> q-------------------------------------------------------------------------q,退出交互配置

再做一次,可以添加多个远端配置。rclone config show - 可以显示当前配置文件信息。

4、直接配置文件

默认配置文件位于 ~/.config/rclone/rclone.conf

[root@localhost rclone-v1.67.0-linux-amd64] cat /root/.config/rclone/rclone.conf
[mysource-old]
type = s3
provider = Ceph
access_key_id = WPDR4OJVAMV5ULEX1EGK
secret_access_key = vfbPHhM0wXxDt1HcB25WdJp5kO2vLHFSqdI61rar
endpoint = http://192.168.188.14:8080

 可以直接对该文件进行编写,源加多个远端配置。

三、数据迁移实例

1、配置文件实例

包含mysource-old源、mysource-new目的两个远端配置,在源和目的间进行数据同步

[root@localhost rclone-v1.67.0-linux-amd64] cat /root/.config/rclone/rclone.conf
[mysource-old]
type = s3
provider = Ceph
access_key_id = WPDR4OJVAMV5ULEX1EGK
secret_access_key = vfbPHhM0wXxDt1HcB25WdJp5kO2vLHFSqdI61rar
endpoint = http://192.168.188.14:8080

[mysource-new]
type = s3
provider = Ceph
access_key_id = KGI5U371ZN746QS4AAKW
secret_access_key = OUemrNwc9yf697BKRZor2X3R8O9cNJF5hxlnh6tG
endpoint = http://192.168.188.28:8080
2、同步实例

以对用户桶test111进行数据同步为例

[root@localhost rclone-v1.67.0-linux-amd64]# ./rclone -Pvv copy mysource-old:test111 mysource-new:test111
Transferred:      277.910 GiB / 445.058 GiB, 62%, 269.129 MiB/s, ETA 10m35s
Transferred:        17631 / 27643, 64%
Elapsed time:     15m57.0s
Transferring:
 * 2023/09/17/i_eac0430e-…-89c7-6992097a60b7.icl: 91% /50.005Mi, 39.989Mi/s, 0s
 * 2023/12/04/i_012a76f1-…-80e8-91a673b6c470.icl: 94% /151.577Mi, 62.807Mi/s, 0s
 * 2023/12/03/i_f5414741-…-aede-239d6e4f1e9f.icl: transferring
 * 2023/12/02/i_e1d0979a-…-bc99-55f8b07fa390.icl: transferring
....

 可以看到,数据同步操作正常。使用copy参数项单向同步源数据至目的侧,不操作目的侧比源端多的文件;使用sync参数项,单向同步源数据至目的端,删除目的侧多余的文件。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代先生.重庆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值