Rclone介绍
rclone是什么,能实现什么功能,直接官方介绍。
Rclone 是一个命令行程序,用于管理云存储上的文件。它是云供应商的网络存储接口的一个功能丰富的替代品。超过 40 种云存储产品支持 rclone,包括 S3 对象存储、企业和消费者文件存储服务以及标准传输协议。
Rclone 具有强大的云等同于 unix 命令 rsync、cp、mv、mount、ls、ncdu、tree、rm 和 cat。Rclone 熟悉的语法包括 shell 管道支持和--dry-run保护。它在命令行、脚本或通过其API使用。
用户称rclone为“云存储的瑞士军刀”、 “无异于魔法的科技”
总之很牛掰就是了,接下来教大家如何如何在服务器上使用rclone挂载网络储存,本文服务器系统为ubuntu,挂载储存为微软的onedrive
安装rclone
直接输入下列命令
curl "https://rclone.org/install.sh | sudo bash"
获取onedrive token
解压压缩包,进入解压又rclone程序的目录,在当前目录打开cmd终端
输入下列命令会自动打开浏览器,这里是onedrive,所以获取的是onedrive的token
./rclone authorize "onedrive"
登录你需要挂载的onedrive账号,然后跳转到下图,勾选后点击接受
网页跳转到success即成功了,这时候回到终端,已经获取到token了,复制{}连同{}一起复制,待会下面挂载需要用到token
配置rclone
shell输入命令rclone config配置储存,然后输入n回车新建一个配置,按照下面代码后面的注释操作
root@instance-20221129-1402:~# rclone config # 配置rclone
2023/02/27 04:07:09 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> This value is required and it has no default.
n/s/q> n # 输入n新建一个配置
Enter name for new remote.
name> onedrive # 输入配置名
Option Storage.
Type of storage to configure.
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, China Mobile, Cloudflare, ArvanCloud, DigitalOcean, Dreamhost, Huawei OBS, IBM COS, IDrive e2, IONOS Cloud, Liara, Lyve Cloud, Minio, Netease, RackCorp, Scaleway, SeaweedFS, StackPath, Storj, Tencent COS, Qiniu and Wasabi
\ (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 / Combine several remotes into one
\ (combine)
12 / Compress a remote
\ (compress)
13 / Dropbox
\ (dropbox)
14 / Encrypt/Decrypt a remote
\ (crypt)
15 / Enterprise File Fabric
\ (filefabric)
16 / FTP
\ (ftp)
17 / Google Cloud Storage (this is not Google Drive)
\ (google cloud storage)
18 / Google Drive
\ (drive)
19 / Google Photos
\ (google photos)
20 / HTTP
\ (http)
21 / Hadoop distributed file system
\ (hdfs)
22 / HiDrive
\ (hidrive)
23 / In memory object storage system.
\ (memory)
24 / Internet Archive
\ (internetarchive)
25 / Jottacloud
\ (jottacloud)
26 / Koofr, Digi Storage and other Koofr-compatible storage providers
\ (koofr)
27 / Local Disk
\ (local)
28 / Mail.ru Cloud
\ (mailru)
29 / Mega
\ (mega)
30 / Microsoft Azure Blob Storage
\ (azureblob)
31 / Microsoft OneDrive
\ (onedrive)
32 / OpenDrive
\ (opendrive)
33 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ (swift)
34 / Oracle Cloud Infrastructure Object Storage
\ (oracleobjectstorage)
35 / Pcloud
\ (pcloud)
36 / Put.io
\ (putio)
37 / QingCloud Object Storage
\ (qingstor)
38 / SMB / CIFS
\ (smb)
39 / SSH/SFTP
\ (sftp)
40 / Sia Decentralized Cloud
\ (sia)
41 / Storj Decentralized Cloud Storage
\ (storj)
42 / Sugarsync
\ (sugarsync)
43 / Transparently chunk/split large files
\ (chunker)
44 / Union merges the contents of several upstream fs
\ (union)
45 / Uptobox
\ (uptobox)
46 / WebDAV
\ (webdav)
47 / Yandex Disk
\ (yandex)
48 / Zoho
\ (zoho)
49 / premiumize.me
\ (premiumizeme)
50 / seafile
\ (seafile)
Storage> 31 # 我们这里配置的是onedrive,在上面选项31
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> # 默认回车
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 # 一般onedrive都是国际版,输入1回车
Edit advanced config?
y) Yes
n) No (default)
y/n> n # 输入n回车
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 # 输入n回车
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> # 填上你的token回车
{"access_token":"eyJ0eXAiOiJKV1QiLCJub25jZSI6IlBtVnFNNDAwNnYxLVJCVTE5M0VHZkxnSkswRC1KRzZLQVp2VVJiS2JINDAiLCJhbGciOiJSUzI1NiIsIng1dCI6Ii1LSTNROW5OUjdiUm9meG1lWm9YcWJIWkdldyIsImtpZCI6Ii1LSTNROW5OUjdiUm9meG1lWm9YcWJIWkdldyJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC82MDE4YjdjNC04N2U2LTQ4NTgtYWRiNi1hYjA3YWQ0N2Y5NTgvIiwiaWF0IjoxNjc3NDcxNDQ0LCJuYmYiOjE2Nzc0NzE0NDQsImV4cCI6MTY3NzQ3NjczMywiYWNjdCI6MCwiYWNyIjoiMSIsImFpbyI6IkFWUUFxLzhUQUFB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MSGPCyLsxMUzBkL0tBLXp5OT3ES5DsbeBI6cAczxoSFdFiLdHDCbAhFmr9Z3UuYd9yiUqfUSP9-aj5QURQMqVBX4UwWPhvafg3nwxFbGdZibt3uEXUfuX0EKgbxkvNGQweTKrJOoOyftIAo9GpEM2Ubbabe96dVPFr_WxUGVJTyHhqUFx7Jj26BR8Wn7S3N8EhLqX8LV4MvIZb1N7Zg-8hKnkUKlbDJKF9giYo-FLCjz-EdzWLg3nr3Z3URW1GC9mK2V-QpOlgjiRVCFu6SqdEvG9zkBpqbQTNbeOpdiHkl1Vig_OLNi3MKbYu92wntCqkALlb9LDDQoeLLTdsy1CxyR3ISqWpm-u1dqKAnWctl-sgRmzO1PmfOzDUq1KgtvxjgphASpm41ekHLsugMKTInC5ae6NU_6t86UYrZpvhs-Zem-iFNgnBmQB6flfzEHy-HALm8WMx-FJ0zaXbGxP4D7BBUVdglZI","expiry":"2023-02-27T13:45:34.0988579+08:00"}
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 # 个人和商业onedrive输入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 (b!YLXLSNs6GUyUIHfxDq7z_QL8U_2Ue1VNpJJwvIj2APwlSOnvM4prQZzCzZRQDFew).
1 / OneDrive (business)
\ (b!YLXLSNs6GUyUIHfxDq7z_QL8U_2Ue1VNpJJwvIj2APwlSOnvM4prQZzCzZRQDFew)
config_driveid> 1 # 输入1回车
Drive OK?
Found drive "root" of type "business"
URL: https://yanboit-my.sharepoint.com/personal/chenliu_yanboit_onmicrosoft_com/Documents
y) Yes (default)
n) No
y/n> y # 输入y回车
Configuration complete.
Options:
- type: onedrive
- token: {"access_token":"eyJ0eXAiOiJKV1QiLCJub25jZSI6IlBtVnFNNDAwNnYxLVJCVTE5M0VHZkxnSkswRC1KRzZLQVp2VVJiS2JINDAiLCJhbGciOiJSUzI1NiIsIng1dCI6Ii1LSTNROW5OUjdiUm9meG1lWm9YcWJIWkdldyIsImtpZCI6Ii1LSTNROW5OUjdiUm9meG1lWm9YcWJIWkdldyJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC82MDE4YjdjNC04N2U2LTQ4NTgtYWRiNi1hYjA3YWQ0N2Y5NTgvIiwiaWF0IjoxNjc3NDcxNDQ0LCJuYmYiOjE2Nzc0NzE0NDQsImV4cCI6MTY3NzQ3NjczMywiYWNjdCI6MCwiYWNyIjoiMSIsImFpbyI6IkFWUUFxLzhUQUFBQU44eHhxR2xpOTRreG4wVnZzVkNraTBFV2hiMDNWdjdNdTYyeWdlazdWOUx6cG10RkVITitZS2xTaGhwYlpZWWFIRXM2MTB5aURrY1E3MS9RREpoWU9KN2Z4Z1E4Ry9uQkg1NDk5c0hka0xJPSIsImFtciI6WyJwd2QiLCJtZmEiXSwiYXBwX2Rpc3BsYXluYW1lIjoicmNsb25lIiwiYXBwaWQiOiJiMTU2NjVkOS1lZGE2LTQwOTItODUzOS0wZWVjMzc2YWZkNTkiLCJhcHBpZGFjciI6IjEiLCJmYW1pbHlfbmFtZSI6IumZiCIsImdpdmVuX25hbWUiOiLnlZkiLCJpZHR5cCI6InVzZXIiLCJpcGFkZHIiOiIxNDYuNTYuMTM5LjE0NSIsIm5hbWUiOiLpmYgg55WZIiwib2lkIjoiNjhhODkxOWUtNGNmNS00YzUxLThhNjgtNGVjMDNkZGUzMzYyIiwicGxhdGYiOiIzIiwicHVpZCI6I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988579+08:00"}
- drive_id: b!YLXLSNs6GUyUIHfxDq7z_QL8U_2Ue1VNpJJwvIj2APwlSOnvM4prQZzCzZRQDFew
- drive_type: business
Keep this "onedrive" remote?
y) Yes this is OK (default)
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挂载到本地
使用screen保持rclone后台
安装screen
ubuntu输入命令
apt-get install screen
创建screen会话
创建一个名为rclone的会话
screen -S rclone
挂载onedrive
输入下列命令挂载onedrive到本地/mnt/onedrive目录下,其中mkdir /mnt/ondedirve创建挂载目录,如果存在就不用创建了,onedrive是刚才的配置名,/mnt/onedrive是挂载到本地储存的路径
mkdir /mnt/onedrive
rclone mount onedrive:/ /mnt/onedrive --cache-dir /tmp --allow-other --vfs-cache-mode writes --vfs-cache-max-age 1m --allow-non-empty
退出screen会话
按:Ctrl+a+d,即可退出screen回到主shell, 此时,程序仍在后台执行;
查看所有screen会话
screen -ls
进入screen某个会话
输入:screen -r 程序进程ID/或者会话名, 返回程序执行进程;
例如,screen -r rclone
进入会话后可以按ctrl+c+k结束会话和窗口
窗口相关操作
Ctrl+a+w: 展示当前会话中的所有窗口;
Ctrl+a+c: 创建新窗口;
Ctrl+a+n: 切换至下一个窗口;
Ctrl+a+p: 切换至上一个窗口;
Ctrl+a+num: 切换至编号为num的窗口;
Ctrl+a+k: 杀死当前窗口;
Ctrl+a+d: 退出当前窗口,程序后台运行;
删除某个会话
screen -S 进程号或者会话名 -X quit
挂载好后在终端进入挂载目录看看有没有文件了,我的onedrive就下面两个文件
cd /mnt/onedrive
ls
挂载到此就结束了,挂载完成
Comments 1 条评论