rclone使用技巧


目录:

1. 连接Microsoft OneDrive

windows下载最新的rclone版本并获取授权token

下载地址

下载后进入目录,打开cmd或者powershell或者win11终端都可:

image-20230329164016378

输入.\rclone.exe authorize "onedrive"命令,会自动打开浏览器开始获取token,认证完成之后终端会输出以下信息,这段json就是之后要用的:

image-20230329164314037

# 安装rclone软件
curl https://rclone.org/install.sh | sudo bash

# 配置rclone
rclone config

# 新建remote连接
e/n/d/r/c/s/q> n

# 输入新的remote的名称
Enter name for new remote.
name> onedrive

# 选择Microsoft OneDrive对应的storage
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
......
31 / Microsoft OneDrive
   \ (onedrive)
......
Storage> 31

# client_id和client_secret设置为空即可
Option client_id.
OAuth Client Id.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_id> 
Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret> 

# 选择region类型,默认1
Option region.
Choose national cloud region for OneDrive.
Choose a number from below, or type in your own string value.
Press Enter for the default (global).
 1 / Microsoft Cloud Global
   \ (global)
 2 / Microsoft Cloud for US Government
   \ (us)
 3 / Microsoft Cloud Germany
   \ (de)
 4 / Azure and Office 365 operated by Vnet Group in China
   \ (cn)
region> 1

# 不用进行高级配置,选no
Edit advanced config?
y) Yes
n) No (default)
y/n> n

# 是否使用web浏览器获取token,选no,下一步使用windows版本的rclone获取token授权
Use web browser to automatically authenticate rclone with remote?
 * Say Y if the machine running rclone has a web browser you can use
 * Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.

y) Yes (default)
n) No
y/n> n

# 输入此前在windows机器上获取到的token字符串,只需要花括号和其中的内容,其余不需要
Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
    rclone authorize "onedrive"
Then paste the result.
Enter a value.
config_token>{"access_token":****}

# 选择onedrive版本,个人版、商业版或其他的,这里选择了个人版,即“OneDrive Personal or Business”
Option config_type.
Type of connection
Choose a number from below, or type in an existing string value.
Press Enter for the default (onedrive).
 1 / OneDrive Personal or Business
   \ (onedrive)
 2 / Root Sharepoint site
   \ (sharepoint)
   / Sharepoint site name or URL
 3 | E.g. mysite or https://contoso.sharepoint.com/sites/mysite
   \ (url)
 4 / Search for a Sharepoint site
   \ (search)
 5 / Type in driveID (advanced)
   \ (driveid)
 6 / Type in SiteID (advanced)
   \ (siteid)
   / Sharepoint server-relative path (advanced)
 7 | E.g. /teams/hr
   \ (path)
config_type> 1

# 选择搜索到的对应版本的实例
Option config_driveid.
Select drive you want to use
Choose a number from below, or type in your own string value.
Press Enter for the default (db0e9f6b0cc4bdb5).
 1 /  (personal)
   \ (**********)
config_driveid> 1

# 确认
Drive OK?

Found drive "root" of type "personal"
URL: https://onedrive.live.com/?cid=db0e9f6b0cc4bdb5

y) Yes (default)
n) No
y/n> y

# 确认配置并退出
Configuration complete.
Options:
- type: onedrive
- token: {"access_token":************}
- drive_id: ************
- drive_type: personal
Keep this "ondrive" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> 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

# 新建挂载目录
mkdir -p /data/onedrive

# 安装挂载所需软件
yum -y install fuse

# 挂载,如需后台挂载加一个--daemon选项即可
rclone mount onedrive:/ /data/onedrive

# 若挂载时提示fusermount3不存在,只需要将/usr/bin/fusermount做一个软链为/usr/bin/fusermount3即可