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 工具使用指南》! 🌟
📚 這份指南蘊含價值巨大,🌟難逢的機遇,切勿錯失良機! ⏰⌛💨
喜歡就分享和按贊!
您的分享和按贊,是我們持續的動力!

 

發表評論

您的電子郵箱地址不會被公開。 必填項已用 * 標註

滾動到頂部