网盘的稳定性一直是网盘用户的痛点。

360倒闭之后许多文件来不及下载,而后又没有合适的地方存储,导致很多人咬牙掏钱买硬盘。然而更多没钱的人选择了其他网盘,比如我,最后选择了OnedriveForBusiness。

但是无论数据存储在哪里,都有丢失的时候,存硬盘里面硬盘会坏,存Onedrive里面……额,订阅哪来的你们也清楚,所以做好数据备份很重要。

所以我一直在寻找这样一个方法,能够帮我完成Onedrive For Business网盘对拷功能。一开始尝试了Flow,然而不知道怎么回事,最开始还能用,到后面就不行了,估计是用的人太多了吧。然后又选择了MultCloud,然而这货有2T流量限制,速度还死慢,作为没钱的我,只好选择了第三条路,利用手头的资源自己搭建。

经过不懈的努力摸索,今晚洗澡的时候我终于萌发出灵感:利用Rclone和VPS进行网盘对拷。下面我具体来说说吧:

搭建环境:Docker环境,镜像:rastasheep/ubuntu-sshd

其中,该镜像的环境是

ubuntu-sshd-910292714-kpnx7 4.4.0-72-generic
用户名、密码均为:root

需要开放的端口包括:22、80、6800,但不限于以上端口。

好了,接下来开始操作:

Reclone安装与挂载

关于Reclone挂在网盘的操作方法,我主要参考了以下两篇文章:

有问题的可以去原帖看一下。

下面开始说我的操作:

首先,需要一台Windows电脑:

打开https://rclone.org/downloads/,下载Windows-AMD64 - 64 Bit压缩包文件,并解压至D:\rclone

然后打开管理员命令提示符,输入

cd /d d:\rclone
rclone authorize "onedrive"

登陆你的账户,获取code,例如我的:

{"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImlCakwxUmNxemhpeTRmcHhJeGRacW9oTTJZayIsImtpZCI6ImlCakwxUmNxemhpeTRmcHhJeGRacW9oTTJZayJ9.eyJhdWQiOiJodHRwczovL2FwaS5vZmZpY2UuY29tL2Rpc2NvdmVyeS8iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9kNWEzODc3YS02ZjBkLTQ4NzUtOWUyMS03MjZhMWJkOTRjMTUvIiwiaWF0IjoxNTI3MzIwOTczLCJuYmYiOj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A7-UjCmkBg","token_type":"Bearer","refresh_token":"AQABAAAAAADX8GCi6Js6SK82TsD2Pb7rnd9hYhHoPmWiPciFQK-L_jFPvodZQ9cadNF6AYwGPH73A-rW3fUWBZ6ZIRNzWeqXotbtGERnsbsY9oSv2dESZf0PAZ0SmlhliTB55p-UHMBhhA02RZzqRO-VYQxC6PYMP20P8PBSvqS7BvkurelSog8L4EpncgyQWpof16aHz6mVgJ3CD-OA7m9zmF3k41TSNhoYxeDznfe4eUYe0vHwbz7Ubfv7xpNwiXKw2JuqkL_UikS-Nmq3_ls-suRZ0VDQxRT7uEc_Z-0H4PeIVH2Cvai7EoQ2WVfZXFZzV8qS_ryjbWspnO6u2_WyReEDUIukHR7BILUOVi141i1L6VXEpw6S-x4TGqKf5q88-BPtbmNz9IwO7nwIVkGe5vY111yVYbQg3j3JzbW0eReByKnSETyypovMEEk_08TYJdD-Ks7AByAUolDrZhFuEUDZlh4VGNNG5DGTf4opoaSNYNt4Rkf9R2b1rL46x66DOBGD2cRMtSUAuy1pNSt1YdddYwV4tiiY15XzCdGiY8Hm39gw9T3eVP1ja_SaQRCiKpZfr63BUO3Hzt1DITgmYqUC_NtDzcyG3c_lbnUrCl4QB2h5f37U8cdRrHJ0uzWwezFL80xmLCdA1Xl-V-OEKjqvWvBNuitNuVbX_20V7wTQgQWSXcwOU1I_BYOwI1aCUmjQBax2GGJQDSVAPu4jJVQOG-7FV8S2__5-ushbSsCqVmqi14ECKQPsm_4pwuDx9W8Tphpbw68fVgSHn3eJqAunovydIAA","expiry":"2018-05-26T16:54:32.8494162+08:00"}

这一段保存好,可以反复使用。

然后打开shell工具,连接你的VPS,开始挂载:

安装相关软件:

apt-get update
apt-get install -y unzip fuse vim

安装Reclone:

下载地址:https://github.com/rclone/rclone/releases/download/v1.48.0/rclone-v1.48.0-linux-amd64.zip

wget https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
chmod 0777 ./rclone-*/rclone
cp ./rclone-*/rclone /usr/bin/
rm -rf ./rclone-*

配置Reclone:

rclone config

然后出现以下内容:

Current remotes:

Name                 Type
====                 ====

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> n #填入n添加新的网盘
name> onedrive #填入自己选取的名字,这里我使用的是"onedrive"
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / A stackable unification remote, which can appear to merge the contents of several remotes
   \ "union"
 2 / Alias for a existing remote
   \ "alias"
 3 / Amazon Drive
   \ "amazon cloud drive"
 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Box
   \ "box"
 7 / Cache a remote
   \ "cache"
 8 / Dropbox
   \ "dropbox"
 9 / Encrypt/Decrypt a remote
   \ "crypt"
10 / FTP Connection
   \ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
12 / Google Drive
   \ "drive"
13 / Hubic
   \ "hubic"
14 / JottaCloud
   \ "jottacloud"
15 / Koofr
   \ "koofr"
16 / Local Disk
   \ "local"
17 / Mega
   \ "mega"
18 / Microsoft Azure Blob Storage
   \ "azureblob"
19 / Microsoft OneDrive
   \ "onedrive"
20 / OpenDrive
   \ "opendrive"
21 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
22 / Pcloud
   \ "pcloud"
23 / QingCloud Object Storage
   \ "qingstor"
24 / SSH/SFTP Connection
   \ "sftp"
25 / Webdav
   \ "webdav"
26 / Yandex Disk
   \ "yandex"
27 / http Connection
   \ "http"
Storage> 19 #看清楚onedrive是哪一个,在我这个版本,是第19个选项。
** See help for onedrive backend at: https://rclone.org/onedrive/ **

Microsoft App Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>  #直接按回车跳过
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>  #再次按回车跳过
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n #无需编辑高级配置选项,填n
Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes
n) No
y/n> n #我们要自己填写code,所以选择n
For this to work, you will need rclone available on a machine that has a web browser available.
Execute the following on your machine:
	rclone authorize "onedrive"
Then paste the result below:
result> {"access_token":"the value of the code","expiry":"2019-07-09T20:37:21.8966666+08:00"}
Choose a number from below, or type in an existing value
 1 / OneDrive Personal or Business
   \ "onedrive"
 2 / Root Sharepoint site
   \ "sharepoint"
 3 / Type in driveID
   \ "driveid"
 4 / Type in SiteID
   \ "siteid"
 5 / Search a Sharepoint site
   \ "search"
Your choice> 1 #我使用的是onedrive for business,所以选择1
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=the name id of Onedrive
Chose drive to use:> 0 #在弹出的存储器中选择你要使用的存储器,一般只有一个,选择0
Found drive 'root' of type 'business', URL: https://sharepointname-my.sharepoint.com/personal/uesrname_domain_com/Documents
Is that okay?
y) Yes
n) No
y/n> y #确认所显示的URL中的域名是否是自己onedrive的域名,如果是,选择y
--------------------
[n]
type = onedrive
token = {"access_token":"the value of the code","expiry":"2019-07-09T20:37:21.8966666+08:00"}
drive_id =the name id of Onedrive
drive_type = business
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y #确认以上信息是否正确,确认无误后选择y
Current remotes:

Name                 Type
====                 ====
onedrive              onedrive

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 #如果你需要继续添加网盘,选择n,退出选择q

重复上述步骤,再连接一个网盘。

到这里,已经完成了网盘在该VPS上的登录认证,并已经映射为一个叫做OneDrive的网盘。

完成上面对两个OFB网盘的连接后,开始对拷:

键入命令rclone copy gdrive1: gdrive2:

表示从gdrive1的根目录开始将所有文件拷贝到gdrive2,同时gdrive2里面的数据可能会被完全清空。

给大家看一下效果:

首先是我在对拷的过程中,用宝塔面板进行了后台服务性能的监控,大概峰值就在这个样子:

峰值

可以看到其实对于CPU的使用并没有像病毒一样的疯狂占满,只在有的时候可能会稍微大一点,所以建议用空的小鸡对拷。另外可以看到,对本机的空间占用几乎没有,所以无论大鸡小鸡都能做到。

在看一下接口流量:

接口流量

可以看出,速度受下载和上传两个因素同时限制。

再看一下十分钟的拷贝速度和效果:

gdrive1
gdrive2

需要提醒的是,因为即使是对拷,用的也是服务器本机的流量,包括下载和上传的流量。所以如果你想拷50G的文件,就要花费至少100G的流量,这是需要计费的。