正文索引 [隐藏]

配置onedrive

我做了视频教程,B站连接:给个一键三连可好https://b23.tv/av87553009

需求:Linux服务器上下载了好多资源。但是Linux没有onedrivegoogle drive的客户端。

那么如何把vps上的文件传到onedrive呢。

这里我们可以用rclone这个工具。

先安装rclone

第一步:我们先在windows上配置一下

下载windows对应位数的压缩包,网址:https://rclone.org/downloads/

先解压到D:\rclone

管理员命令提示符(cmd)输入下面的命令,回车

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

会自动打开浏览器让你登录你的onedrive账户

点击授权后浏览器显示如图

回到cmd,发现多了一大串字符。复制花括号里的所有字符,新建一个文档保存,一会要用。

第二步:开始配置Linux端

打开你的SHH工具连接vps,我的是ubuntu系统,输入:

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

然后输入:

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-*

然后输入:

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
显示如下
name>
这里我们起个名字

第四步:出现一堆网盘序号

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 / Transparently chunk/split large files
   \ "chunker"
32 / Union merges the contents of several remotes
   \ "union"
33 / Webdav
   \ "webdav"
34 / Yandex Disk
   \ "yandex"
35 / http Connection
   \ "http"
36 / premiumize.me
   \ "premiumizeme"
Storage>

找到对应的序号,我这里onedrive是23号。
输入23回车

第五步:接下来

** 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> 

默认空着,直接回车
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> 

这里选择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
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"
Then paste the result below:
result>

这里我们输入刚才复制的一大堆字符串
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

Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!5aaxzEKnQ0moUdSJN5FFiz18jOg3bKJDpnlLne7FeEjh0fnzsP3TSIpazFa4zHn9
Chose drive to use:>

这里显示出来了网盘序号,输入0
Found drive 'root' of type 'business', URL: https://ememe-my.sharepoint.com/personal/admin_ememe_onmicrosoft_com/Documents
Is that okay?
y) Yes (default)
n) No
y/n> 

配置好了。输入y

drive_id = b!5aaxzEKnQ0moUdSJN5FFiz18jOg3bKJDpnlLne7FeEjh0fnzsP3TSIpazFa4zHn9
drive_type = business
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d

到这里我就就已经配置完成,输入y
然后就没事了。输入q退出rclone就行

第六步:别忘了还需要安装个screen

apt-get install -y screen    //这是debian系

centos系安装screen需要使用yum install screen

上传命令

rclone move source:path dest:path    //别急看完下面的

screen rclone move /root/download onedrive1:/upload --transfers 32 -P    //完整的命令

参数详解:

source:path是本地目录,dest:path是云端目录

其中dest是网盘名称,就你刚才随便取的那个path就是目录

你可以指定上传到哪一个文件夹

比如说,

我要把本地的/root/download目录下所有的文件移动到onedrive里面的/upload文件夹里面

命令应该是rclone move /root/download onedrive1:/upload

但是这样上传的话,他一直在前台上传,占用你的ssh。
想让他变成后台,在前面加上screen

命令就是:screen rclone move /root/download onedrive1:/upload

这样你就可以关掉ssh,他就可以在后台上传

如果文件目录比较复杂,而且文件数量庞大
可以提高线程,他默认是4线程,测试后发现100M带宽32线程效果最好。(根据你的vps而定线程。)

可以在后面再加一个参数 -P(大写)显示上传详情

screen rclone move /root/download onedrive1:/upload –transfers 32 -P

screen

等你想看看传完了没有的时候,
screen -ls就可以看到后台screen进程。

配置google drive盘

1.配置

google drive盘有区分

个人盘团队盘

这里我们先配置团队盘,个人盘也同理。

  1. 输入 rclone config
  2. 输入 n
  3. 提示如下:
  4. 给本次配置的网盘起个名字
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
name> 
这网盘起个名字
12 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
13 / Google Drive
   \ "drive"
14 / Google Photos
   \ "google photos"
   选择13
** See help for drive backend at: https://rclone.org/drive/ **

Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a string value. Press Enter for the default ("").
client_id> 
空着就行,回车

翻译:

建议您设置自己的Google Application Client ID。有关如何创建自己的示例,请参见https://rclone.org/drive/#making-your-own-client-id。如果将此空白留空,它将使用性能低下的内部密钥。输入一个字符串值。按Enter作为默认值(“”)。

Google Application Client Secret
Setting your own is recommended.
Enter a string value. Press Enter for the default ("").
client_secret> 
空着,就行

翻译:

建议设置您自己的Google Application Client Secret。输入一个字符串值。按Enter作为默认值(“”)。

Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / Full access all files, excluding Application Data Folder.
   \ "drive"
 2 / Read-only access to file metadata and file contents.
   \ "drive.readonly"
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ "drive.file"
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ "drive.appfolder"
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ "drive.metadata.readonly"
scope> 
输入1

大概的机翻:

rclone从驱动器请求访问时应使用的范围。输入一个字符串值。按Enter作为默认值(“”)。

从下面选择一个数字,或键入您自己的值

1 /完全访问所有文件,但不包括应用程序数据文件夹。

\“ drive”

2 /对文件元数据和文件内容的只读访问。

\“ drive.readonly” /仅访问由rclone创建的文件。

3 |这些在驱动器网站上可见。 |当用户取消对应用程序的授权时,文件授权将被吊销。 \“ drive.file” /允许对“应用程序数据”文件夹进行读写访问。

4 |这在驱动器网站上不可见。 \“ drive.appfolder” /允许只读访问文件元数据,但

5 |不允许任何访问来读取或下载文件内容。 \“

ID of the root folder
Leave blank normally.

Fill in to access "Computers" folders (see docs), or for rclone to use
a non root folder as its starting point.

Note that if this is blank, the first time rclone runs it will fill it
in with the ID of the root folder.

Enter a string value. Press Enter for the default ("").
root_folder_id> 
空着,回车

机翻:

根文件夹的ID通常保留空白。填写以访问“计算机”文件夹(请参阅文档),或让rclone使用非根文件夹作为起点。请注意,如果为空,则第一次运行rclone时,它将使用根文件夹的ID进行填充。输入一个字符串值。按Enter作为默认值(“”)。

Service Account Credentials JSON file path 
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file> 
空着,回车

机翻:

服务帐户凭据JSON文件路径通常留空。仅当您要使用SA而不是交互式登录时才需要。输入一个字符串值。按Enter作为默认值

Service Account Credentials JSON file path 
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file> 
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> 
空着,回车

机翻:

服务帐户凭据JSON文件路径通常留空。仅当您要使用SA而不是交互式登录时才需要。输入一个字符串值。按Enter作为默认值(“”)。 service_account_file>编辑高级配置?

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

机翻:

远程配置使用自动配置? *如果不确定,则说Y *如果在远程或无头机器上工作,请说N

Please go to the following link:

https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id20264815644.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awgoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=kXGnW8AtxDZinUY7auTP9w

Log in and authorize rclone for access
Enter verification code> 
把提示的这个连接放到浏览器打开

登录你的账户

授权允许,出现这个代码,复制粘贴到SSH工具,回车

“`意意
Configure this as a team drive?
y) Yes
n) No (default)
y/n>
注意注意注意,配置个人盘就输入n,配置团队盘输入y

<pre><code class=""><br />**机翻:**

将此配置为团队盘吗?

“`shell
Fetching team drive list…
Choose a number from below, or type in your own value
1 / admin-lifan-ooo-fjhechuan
\ “0ABiUAIea2iibk9PVA”
2 / chyon
\ “0AP6QmoAnW_Qbk9PVA”
3 / hechuan-MoeClub
\ “0APYqQlQeZnpwU9PVA”
4 / hechuan
\ “0AG97tphYvnZ_U9PVA”
5 / hy-fjhechuan
\ “0ANzkcvxKCBWak9PVA”
Enter a Team Drive ID>
列出了我账户下所有的团队盘。你想配置哪个就输入对应的序号。
我想用5号,就输入5

[google_hy]
type = drive
scope = drive
token = {"access_token":"ya29.Il-9B-x15fy1sfTMSML-MkqVgTq2W0W_VVqluwoWXuioeglrF-LnjinhMGDyqa0HDk0SYTvXkAMZviYx2yM40AnMl4IK-3QhAf1FE54X2hVOiIuDpiRsU3oClksw","token_type":"Bearer","refresh_token":"1//03ztJYkqbqDnuCgYIARAAGAMSNwF-L9IrKCRqVpsgKMqWSa0an_uMblaHiJS-FPCB9T6lGj2taVQ0U7og5m3z1FOuC-UlNDJL204","expiry":"2020-02-07T14:13:26.261934522Z"}

team_drive = 0ANzkcvxKCBWaUk9PVA
--------------------

y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> 
到这里就完成团队盘的配置了。

2.上传

上传之前别忘了

还需要安装个screen

apt-get install -y screen

上传命令

screen rclone move /1/aria2/ onedrive_rive:/upload --transfers 32 -P

测试一下上传。我把服务器本地的/1/2目录里面的文件复制到谷歌云的upload目录里。

开启12线程,显示上传详情,

命令就是:

screen rclone copy /1/2/ google_hy_fjhechuan:/upload --transfers 12 -P