Rclone连接Onedrive速度慢?转存上传限速?配置API加速

在使用 Rclone 传输文件到 OneDrive 时,可能会遇到速度很慢、断线等问题……

为何Rclone连接Onedrive速度慢?

根本原因是触发了OneDrive API的限制,而默认的Rclone内置API被多人同时使用,所以这些问题也越来越明显……

Rclone连接Onedrive速度慢?转存上传限速?配置API加速

使用自建私有API连接OneDrive可以大大改善这些情况,而且对于三个月的Office 365 E5开发者试用版,偶尔使用Rclone会有自动续费的可能,而不是刻意刷API,更加安全和稳定。

此外,自建API也可以被其他账户和其他应用程序使用。

如果是Google Drive自建API,请参考这篇教程 ▼

Rclone连接Onedrive速度测试

前者是网友测试使用Rclone默认的API 连接Onedrive的速度▼

Rclone连接Onedrive速度测试  前者是网友测试使用Rclone默认的API 连接Onedrive的速度 第3张

后者是网友测试使用自己申请的微软API 连接Onedrive的速度▼

后者是网友测试使用自己申请的微软API 连接Onedrive的速度 第4张

  • 可以清楚的看到,速度相差10倍以上。

如何创建微软 Onedrive 网盘API?

微软Azure管理中心获取Client ID和Client secret的方法,请点击下方链接查看如何创建微软 Onedrive 网盘API ▼

Rclone获取token

在本地电脑上下载 Rclone ▼

以Windows为例,解压后进入rclone.exe所在文件夹,在资源管理器地址栏中输入 cmd 回车,即可在当前路径打开命令提示符。

替换以下命令中的Client_IDClient_secret 并执行 ▼

rclone authorize "onedrive" "Client_ID" "Client_secret"
  • 接下来会弹出一个浏览器,要求你登录你的帐户进行授权。

授权后,命令提示符窗口中会出现以下消息:

If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth
Log in and authorize rclone for access
Waiting for code...
Got code
Paste the following into your remote machine --->
{"access_token":"xxxxxxxxxxxxxxxxxx","expiry":"2024-05-15T21:18:39.5036298+08:00"}
<---End paste
  • {"access_token":"xxxxxxxxxxxxxxxxxx","expiry":"2024-05-15T21:18:39.5036298+08:00"}这段全部内容(包括括号)是token,复制并保存。

Rclone 连接 OneDrive

SSH输入以下命令 ▼

rclone config

会出现如下信息,请参考以下说明进行操作 ▼

  • 注意事项:因为RCLONE会不定期更新,所以看到这个教程的时候,菜单选项可能有轻微的变化,但是大意不会变,不要想着就复制操作。
$ rclone config

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 # 输入网盘名称,类似标签,这是用来区别不同的网盘。
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 / 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, Digital Ocean, Dreamhost, IBM COS, Lyve Cloud, Minio, RackCorp, SeaweedFS, and Tencent COS
\ (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 / Compress a remote
\ (compress)
12 / Dropbox
\ (dropbox)
13 / Encrypt/Decrypt a remote
\ (crypt)
14 / Enterprise File Fabric
\ (filefabric)
15 / FTP Connection
\ (ftp)
16 / Google Cloud Storage (this is not Google Drive)
\ (google cloud storage)
17 / Google Drive
\ (drive)
18 / Google Photos
\ (google photos)
19 / Hadoop distributed file system
\ (hdfs)
20 / Hubic
\ (hubic)
21 / In memory object storage system.
\ (memory)
22 / Jottacloud
\ (jottacloud)
23 / Koofr, Digi Storage and other Koofr-compatible storage providers
\ (koofr)
24 / Local Disk
\ (local)
25 / Mail.ru Cloud
\ (mailru)
26 / Mega
\ (mega)
27 / Microsoft Azure Blob Storage
\ (azureblob)
28 / Microsoft OneDrive
\ (onedrive)
29 / OpenDrive
\ (opendrive)
30 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ (swift)
31 / Pcloud
\ (pcloud)
32 / Put.io
\ (putio)
33 / QingCloud Object Storage
\ (qingstor)
34 / SSH/SFTP Connection
\ (sftp)
35 / Sia Decentralized Cloud
\ (sia)
36 / Storj Decentralized Cloud Storage
\ (storj)
37 / Sugarsync
\ (sugarsync)
38 / Transparently chunk/split large files
\ (chunker)
39 / Union merges the contents of several upstream fs
\ (union)
40 / Uptobox
\ (uptobox)
41 / Webdav
\ (webdav)
42 / Yandex Disk
\ (yandex)
43 / Zoho
\ (zoho)
44 / http Connection
\ (http)
45 / premiumize.me
\ (premiumizeme)
46 / seafile
\ (seafile)
Storage> 28 # 输入28表示选择Microsoft OneDrive
Option client_id.
OAuth Client Id.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_id> # 输入 Client Id (客户端 ID)
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> # 输入 Client Secret (客户端密码)
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n # 输入 n
Remote config
Make sure your Redirect URL is set to "http://localhost:53682/" in your custom 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 # 输入 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 (same rclone version recommended) :
rclone authorize "onedrive" "client_id" "client_secret"
Then paste the result below:
result> {"access_token":"XXXXXXXXX","expiry":"2024-05-15T21:18:39.5036298+08:00"} # 输入 token
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,所以输入1
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=xxxxxxxxxxxxxx
Chose drive to use:> 0 # 检测到网盘,此处号码是0,所以输入0
Found drive 'root' of type 'business', URL: https:// xxx.sharepoint. com/personal/xxxxxx/Documents
Is that okay?
y) Yes
n) No
y/n> y # 请你确认,如果没有问题,请输入 y

--------------------
[od-e5-api]
type = onedrive
client_id = xxxxxxxxxx
client_secret = xxxxxxxxxxxxxxxx
token = {"access_token":"xxxxxxxxxxxxxxxxxx","expiry":"2024-05-15T21:18:39.5036298+08:00"}
drive_id = xxxxxxxxxxxxxxxxxxxxxxxxx
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 # 输入 q 退出
  • 至此,Rclone已经使用自建API成功连接到OneDrive网盘。

配置完成后,你可以使用如下rclone命令查看:

列出 onedrive 顶层的目录 ▼

rclone lsd onedrive:

列出 onedrive 中的所有文件 ▼

rclone ls onedrive:

将本地目录复制到名称为backup的 onedrive 目录 ▼

rclone copy /home/source onedrive:backup

复制剪切删除命令

复制Rclone配置文件到onedrive的网盘的根目录 ▼

rclone copy /root/.config/rclone/rclone.conf onedrive:/

复制本地 /home/backup 到配置名为onedrive的网盘的backup目录,反之亦然 ▼

rclone copy --progress /home/backup onedrive:backup
  • 通过添加此参数 --ignore-existing 可以忽略在网盘上已备份的文件,这相当于增量备份 ▼
rclone copy --ignore-existing /home/backup onedrive:backup

复制本地CWP手动备份文件到配置名为onedrive的网盘的backup目录,反之亦然 ▼

rclone copy --progress /newbackup/full/manual/accounts/eloha.tar.gz onedrive:cwp-newbackup/full/manual/accounts/

从onedrive的网盘,复制CWP自动定时备份文件到本地 /newbackup 目录 ▼

rclone copy --progress onedrive:cwp-newbackup/full/daily/Friday/accounts/eloha.tar.gz /newbackup/

rclone copy --progress onedrive:cwp-backup2/ /home/backup2/

从onedrive的网盘,复制CWP手动备份文件到本地 /newbackup/newbackup/full/manual/accounts/ 目录▼

rclone copy --progress onedrive:cwp-newbackup/full/manual/accounts/eloha.tar.gz /newbackup/newbackup/full/manual/accounts/

从onedrive的网盘,复制VestaCP备份文件到本地 /home/backup 目录 ▼

rclone copy --progress onedrive:backup/admin.2018-04-12_13-10-02.tar /home/backup

移动(剪切)命令 ▼

rclone move /home/backup onedrive:backup

删除配置名为onedrive的网盘的backup目录▼

rclone delete onedrive:backup

创建配置名为onedrive的网盘的backup目录 ▼

rclone mkdir onedrive:backup

复制 ▼

rclone copy

移动 ▼

rclone move

删除 ▼

rclone delete

同步 ▼

rclone sync

更多Rclone命令使用教程,请参考下方的Rclone命令大全 ▼

如何挂载OneDrive?

如果需要挂载到本地目录,可以参考我们之前的Rclone挂载教程 ▼

OneDrive 私有API的限制

虽然自建私有API可以提升上传体验,但是如果使用太频繁,上传可能会受到限制。

微软 OneDrive API 最大限制阈值是多少?

微软没有明确说明 OneDrive API 的最大限制阀值是多少,以下是原文档:

根据使用情况,我们会对阈值进行微调,以便用户可以使用最大数量的资源,而不会降低可靠性和性能。

  • 通过查看其他类型 API 限制的描述可以猜到,有两个限制,总数和频率。
  • 总数是一天可以调用的次数,频率是每分钟可以调用的次数。
  • 并且一旦达到限制阈值,文件的上传就会受到限制。
  • 既然从官方文档中无法得到准确的值,那么是否可以通过实际测试得到这个准确的值呢?
  • 答案是否定的。 实际测试中没有发现任何规律,所以这个限制是动态调整的,也符合官方文档。

如何避免受到 OneDrive API 限制?

短时间内不要上传太多文件,文件大小无所谓,关键是文件数量。

关于Office 365 E5自动续费问题:

  • 根据网友多年使用开发者试用版的经验,只要使用自建私有API,就可以续订。
  • 至于频率,没有标准,也不是越多越好。
  • 刻意刷API可能得不偿失,尤其是使用GitHub Actions,因为服务器是微软Azure,这么多人用类似的方式无意义刷API,微软Azure想要识别是很容易。

希望陈沩亮博客( https://www.chenweiliang.com/ ) 分享的《Rclone连接Onedrive速度慢?转存上传限速?配置API加速》,对您有帮助。

欢迎分享本文链接:https://www.chenweiliang.com/cwl-27906.html

欢迎加入陈沩亮博客的 Telegram 频道,获取最新更新!

🔔 率先在频道置顶目录获取宝贵的《ChatGPT 内容营销 AI 工具使用指南》!🌟
📚 这份指南蕴含价值巨大,🌟难逢的机遇,切勿错失良机!⏰⌛💨
喜欢就分享和按赞!
您的分享和按赞,是我们持续的动力!

 

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

滚动到顶部