rclone
在shell里运行安装
singularity pull rclone.sif docker://rclone/rclone:latest #安装rclone
singularity run rclone.sif #运行rclone
以下 rclone 均用 singularity run rclone.sif 代替(建议写到alias 里面alias rclone='singularity run rclone.sif')
1.获取Token
在Windows电脑上下载Rclone,下载地址:https://rclone.org/downloads/ ,然后解压,使用cmd进入解压后的文件夹
./rclone.exe authorize "onedrive"
然后会跳转到浏览器的登录页面,输入账号密码登录成功后cmd命令框就会返回你的token
框起来的就是要复制保存的,后期会用
2.Linux安装onedirve
官方提供的脚本
curl https://rclone.org/install.sh | bash
3.配置
安装好之后输入:
rclone config
会看到:
2022/04/27 09:01:17 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>
输入 n
新建配置。
name
可以随便输入,
然后会出现挂载的服务类型,如下:
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, 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>
直接输入序号,比如我挂载的是 OneDrive 就可以输入 28
,
client_id
可以直接回车默认,
client_secret
也可以直接回车默认,
然后会出现 OneDrive 区域选择,如下:
1234567891011Choose national cloud region for OneDrive.
Enter a string value. Press Enter for the default ("global").
Choose a number from below, or type in your own value
1 / Microsoft Cloud Global
\ "global"
2 / Microsoft Cloud for US Government
\ "us"
3 / Microsoft Cloud Germany
\ "de"
4 / Azure and Office 365 operated by 21Vianet in China
\ "cn"
可以直接输入 1
选择全球,
然后是选择是否进行高级配置,如下:
123dit advanced config? (y/n)
y) Yes
n) No (default)
可以输入 n
,
接着是自动配置选择,如下:
123456Remote 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
可以输入 n
,
这里需要获取授权码:
Copy1234567891011For 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:
然后复制刚刚保存的token包括首尾的 {} ,到 Linux 终端粘贴。
然后是选择 OneDrive 的类型,如下:
123456789101112131415Choose a number from below, or type in an existing value
1 / OneDrive Personal or Business
\ "onedrive"
2 / Root Sharepoint site
\ "sharepoint"
3 / Sharepoint site name or URL (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"
7 / Sharepoint server-relative path (advanced, e.g. /teams/hr)
\ "path"
可以输入 1
,
然后会显示找到的 OneDrive 账户,如下:
12Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!b_xnJJqyBMSVPjgvhvbP8XmJ_M_dMjhzrbhnaWknnbKqNBm8MTqM3kvEtW67P
根据提示输入序号,
这里会根据你输入的序号查找账户,如下:
1234Found drive 'root' of type 'business', URL: https://xxx-my.sharepoint.com/personal/changbin_xxx_onmicrosoft_com/Documents
Is that okay?
y) Yes (default)
n) No
确认无误后输入 y
,
接着会显示你选择的配置信息,确认无误后输入 y
保存配置。
4.挂载
root权限安装fuse3
sudo apt install fuse3
进入挂载目录上一级
cd ~
输入:root用户建议用下面这条
rclone mount onedrive_ljc:/ onedrive_disk/ --allow-other --attr-timeout 5m --vfs-cache-mode full --vfs-cache-max-age 48h --vfs-cache-max-size 30G --vfs-read-chunk-size-limit 100M --buffer-size 800M --daemon
非root用户(去除--allow-other,否则会报错):
rclone mount onedrive_ljc:/ljc/ onedrive_ljc/ --attr-timeout 5m --vfs-cache-mode full --vfs-cache-max-age 48h --vfs-cache-max-size 10G --vfs-read-chunk-size-limit 100M --buffer-size 800M --daemon
rclone mount configName:OneDriveLocation dir --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
其中的 configName
就是配置名称,OneDriveLocation
就是要挂载的 OneDrive 目录,dir
就是要挂载到的本地目录。
例如我要把一个名为 myonedrive
的配置挂载到本地的 /myonedrive
目录
没有目录的话先创建:mkdir myonedrive
我可以这样写:
nohup rclone mount myonedrive:/ /root/myonedrive --vfs-cache-mode writes --vfs-cache-max-age 10s --onedrive-chunk-size 100M >/dev/null 2>&1 &
我这里挂载的是整个 OneDrive 网盘,所以我写的是 OneDrive 的根目录 /
。
挂载完成后不会显示任何内容,可以再开一个终端,输入 df -h
查看磁盘空间,如下:
成功挂载!!
常用指令
rclone mkdir remote:path [flags]
rclone [命令] onedrive_ljc:/
上传:
rclone copy /home/data/ssy307/data/GOLP/Figure8/sc.cd8T_human_2000.RDS onedrive_ljc:/ --transfers 32 -P
下载:
rclone copy onedrive_ljc:/sc.cd8T_human_2000.RDS /home/data/ssy307/Onedrive --transfers 32 -P
rclone copy – 复制
rclone sync – 同步 将目录内容同步到网盘目录
rclone move – 移动 将目录内文件移动到网盘,默认删除路径文件
rclone purge – 删除路径及所有文件
rclone delete – 删除路径所有文件但不删除路径
rclone mkdir – 创建目录
rclone rmdir – 删除目录
rclone check – 检查目标文件与源文件是否匹配
rclone ls – 列出指定路径下的所有的文件以及文件大小
rclone lsf --max-depth 1 – 列出指定路径下的所有的文件以及文件大小且停止递归
rclone lsl – 仅列出对象的修改时间,大小和路径
rclone lsd – 仅列出目录
注意ls
和lsl
默认是递归的 – 使用--max-depth 1
来停止递归。.
其他列表命令lsd
,lsf
,lsjson
默认不递归 – 使用R
使其递归。.
第六步:别忘了还需要安装个screen
apt-get install -y screen //这是debian系
centos系安装screen需要使用yum install screen
上传命令
rclone move source:path dest:path //别急看完下面的
若要加screen 后台运行,rclone 换成必须singularity run rclone.sif alias没用
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进程。
此处评论已关闭