Rclone 是一个用于多个云平台之间同步文件和目录的命令行工具,其支持多种运营商网盘。
安装与配置
下载安装rclone
windows版本:下载rclone并解压
Linux版本:
1
curl https://rclone.org/install.sh | sudo bash
配置OneDrive
在目录下打开cmd运行命令
rclone authorize "onedrive"
世纪互联运行的命令
rclone authorize onedrive "应用程序(客户端)ID" "客户端密码值" --onedrive-is-21vianet-version=true
复制授权码:
{"access_token":"xxxx"}
配置
1
rclone config
设置步骤如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165root@localhost:~# rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> 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 / 1Fichier
\ "fichier"
2 / Alias for an 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 / Citrix Sharefile
\ "sharefile"
9 / Dropbox
\ "dropbox"
10 / Encrypt/Decrypt a remote
\ "crypt"
11 / FTP Connection
\ "ftp"
12 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
13 / Google Drive
\ "drive"
14 / Google Photos
\ "google photos"
15 / Hubic
\ "hubic"
16 / In memory object storage system.
\ "memory"
17 / Jottacloud
\ "jottacloud"
18 / Koofr
\ "koofr"
19 / Local Disk
\ "local"
20 / Mail.ru Cloud
\ "mailru"
21 / Mega
\ "mega"
22 / Microsoft Azure Blob Storage
\ "azureblob"
23 / Microsoft OneDrive
\ "onedrive"
24 / OpenDrive
\ "opendrive"
25 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
26 / Pcloud
\ "pcloud"
27 / Put.io
\ "putio"
28 / QingCloud Object Storage
\ "qingstor"
29 / SSH/SFTP Connection
\ "sftp"
30 / Sugarsync
\ "sugarsync"
31 / Tardigrade Decentralized Cloud Storage
\ "tardigrade"
32 / Transparently chunk/split large files
\ "chunker"
33 / Union merges the contents of several upstream fs
\ "union"
34 / Webdav
\ "webdav"
35 / Yandex Disk
\ "yandex"
36 / http Connection
\ "http"
37 / premiumize.me
\ "premiumizeme"
38 / seafile
\ "seafile"
Storage> 23 #选择第23项的onedrive
** 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 (default)
y/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 (default)
n) No
y/n> n #选择n
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 below:
result> {"access_token":"xxxxxxxx"} #输入授权码
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 #选择1,onedrive
Found 1 drives, please select the one you want to use:
0: (personal) id=xxxxxxxx
Chose drive to use:> 0 #选择挂载的onedrive网盘
Found drive 'root' of type 'personal', URL: https://onedrive.live.com/?cid=xxxxxxxx
Is that okay?
y) Yes (default)
n) No
y/n> #跳过
--------------------
[myone]
type = onedrive
token = {"access_token":"xxxxxxxx"}
drive_id = xxxxxx
drive_type = personal
--------------------
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>
配置谷歌网盘
运行命令:
1 | rclone config |
设置步骤如下:
1 | $ ./rclone.exe config |
获取配置文件
搜索 ,windows下正常都在 C:\Users\你的用户名\\.config\rclone
目录下,Linux正常都在 ./.config/rclone/
目录下
使用教程
常用命令:
1 | rclone config - 以控制会话的形式添加rclone的配置,配置保存在.rclone.conf文件中。 |
显示网盘上的目录
1
2rclone lsd onedrive: #onedrive是上面设置的名称
rclone lsd gdrive: #gdrive是上面设置的名称拷贝谷歌网盘上的文件到Onedrive
1
2
3
4!rclone copy gdrive:music onedrive:音乐 --ignore-existing --config ./music/rclone.conf
# --config xxxx.conf 表示指定配置文件
# --ignore-existing表示跳过已存在的文件
# 此命令表示将谷歌网盘下的music目录复制到Onedrive网盘下的音乐目录挂在Onedrive
1
rclone mount onedrive:音乐 music --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --config /content/gdrive/My\ Drive/music/rclone.conf
Linux上挂载网盘
新建Linux下的文件夹
1
2rm -rf /root/music #删除已有的目录
mkdir /root/music #新建目录挂载磁盘
下载脚本
1
wget -N --no-check-certificate https://raw.githubusercontent.com/x91270/Centos/master/rcloned
使用
vim rcloned
修改脚本项1
2
3NAME="myone" #创建的rclone名,本文此处填ojbk
REMOTE="音乐" #远程挂载地址对应的文件夹,是你OneDrive对应的具体目录
LOCAL="/root/music" #在本机上的挂载地址启动脚本
rcloned start
挂载成功后,输入
df -h
命令查看设置开机启动
1
2
3
4mv rcloned /etc/init.d/rcloned #移动rcloned到init(开机启动目录)下
chmod +x /etc/init.d/rcloned #给rcloned可执行权限
chkconfig rcloned on #设置自启动
bash /etc/init.d/rcloned start #启动rclone