type
status
date
slug
summary
tags
category
icon
password
本文介绍rclone相关用法的配置、命令、语法等。
1. 配置
在使用rclone的初始,首要的是rclone配置。由于对象存储系统的身份验证非常复杂,因此将它们保存在配置文件中。生成配置最容易的方法就是运行rclone的config选项:
下面是rclone支持列表:
- Chunker – transparently splits large files for other remotes
- Crypt – to encrypt other remotes
2. 用法
rclone同步一个目录树从一个存储系统到另外一个。语法如下:
源路径和目的路径根据在配置文件中为存储系统指定的名称来指定,然后接上子路径,例如:”drive:myfolder”来查看在Google Drive中的”myfolder”路径。可以在配置文件中定义多个你喜欢的存储路径。
3. 子命令(Subcommands)
rclone使用子命令系统,例如:
最常用的主要rclone命令:
- rclone config – Enter an interactive configuration session.进入交互式配置会话。
- rclone copy – Copy files from source to dest, skipping already copied.将文件从源复制到目的地,跳过已复制的文件。
- rclone sync – Make source and dest identical, modifying destination only.使源和目的文件一直,仅修改目的。
- rclone move – Move files from source to dest.将文件从源地址移动到目的地。
- rclone delete – Remove the contents of path.删除路径的指定的内容。
- rclone purge – Remove the path and all of its contents.删除路径已经路径下的所有内容。
- rclone mkdir – Make the path if it doesn’t already exist.如果指定路径不存在则创建。
- rclone rmdir – Remove the path.删除指定路径。
- rclone rmdirs – Remove any empty directories under the path.删除指定路径下的所有空目录。
- rclone check – Check if the files in the source and destination match.检查源和目录路径下的文件是否匹配。
- rclone ls – List all the objects in the path with size and path.用大小和路径列出指定路径下的所有对象。
- rclone lsd – List all directories/containers/buckets in the path.列出指定目录下的所有目录(directories)/容器(containers)/存储桶(buckets)。
- rclone lsl – List all the objects in the path with size, modification time and path.以大小、修改时间和路径列出指定路径下的所有对象。
- rclone md5sum – Produce an md5sum file for all the objects in the path.为指定路径下的所有对象生成一个md5sum文件。
- rclone sha1sum – Produce a sha1sum file for all the objects in the path.为指定路径下的所有对象生成一个sha1sum文件。
- rclone size – Return the total size and number of objects in remote:path.返回
remote:path路径下对象的总共大小和数量。
- rclone version – Show the version number.显示rclone版本号。
- rclone cleanup – Clean up the remote if possible.尽可能清理远端(回收站)。
- rclone dedupe – Interactively find duplicate files and delete/rename them.交互式查找重复文件并删除/重命名。
- rclone authorize – Remote authorization.远端认证。
- rclone cat – Concatenate any files and send them to stdout.连接任意文件并发送到标准输出(stdout)。
- rclone copyto – Copy files from source to dest, skipping already copied.将文件从源复制到目的地,跳过已经复制的。
- rclone genautocomplete – Output shell completion scripts for rclone.输出rclone的shell完成脚本。
- rclone gendocs – Output markdown docs for rclone to the directory supplied.将rclone提供的目录输出为markdown文档。
- rclone listremotes – List all the remotes in the config file.列出配置文件中的所有远端。
- rclone mount – Mount the remote as a mountpoint.将远端挂载为一个挂载点。
- rclone moveto – Move file or directory from source to dest.将文件或者目录从源移动到目的。
- rclone obscure – Obscure password for use in the rclone.conf模糊在
rclone.conf中使用的密码。
- rclone cryptcheck – Check the integrity of a crypted remote.检查加密远端的完整性。
- rclone about – Get quota information from the remote.从远端获取配额信息。
【完整命令索引】
4. 复制单个文件
rclone通常会同步或复制目录。如果源指向文件,rclone只会复制该文件。目标必须指向目录,否则rclone将给出错误:
举个例子,假如你有一个名为
test.jpg的文件,可以通过以下方式拷贝即,将远端的
test.jpg文件拷贝到本地/tmp/download目录下。建议在拷贝单个文件时使用copy而不是sync命令。虽然等效,但是copy内存占用更低。
5. 远端(remote)路径语法
这里说明以下给rclone传递的路径格式
5.1 /path/to/dir
这种格式指本地文件系统。在windows系统中,本地目录使用
\来代替/,而远程目录仍然使用/。5.2 remote:path/to/dir
这种就是在
remote:上使用的路径格式,这里的remote:就是通过rclone config配置的远端。5.3 remote:/path/to/dir
在大多数后端来讲,
remote:path/to/dir和remote:/path/to/dir是等效的,即都指向同一目录。在极少数的远端(FTP,SFTP,Dropbox for business)会指向另外的目录。在这些远端中,不带前导/的路径将引用你的home目录,而带前导/的路径将引用根目录。5.4 : backend:path/to/dir
这是用于动态创建远端的高级形式。
backend是后端的名称或前缀(配置文件中的type参数),并且后端的所有配置都应在命令行中(或在环境变量中)提供。示例
6. shell引用
在shell命令行中使用相关命令。
6.1 Linux / OSX
如果名称包含空格或shell元字符(例如
*,?,$,',"等),则必须用引号引起来。默认情况下,使用单引号'。如果说你的名称需要使用单引号
',那么需要使用双引号"包起来。当然还有一些比较复杂的,自行搜索。
6.2 Windows
名称中存在空格,则需要使用双引号
"",如7. 拷贝名称包含:的文件或目录
rclone使用
:来标记一个远程名字。但是,这是非Windows操作系统中的有效文件名组件。远程名称解析器只会搜索:直到第一个/,因此,如果您需要对这样的文件或目录执行操作,请使用以/开头的完整路径,或使用./作为当前目录前缀。同步一个名称为
sync:me的目录到remote:远端:8. 服务器端复制(Server Side Copy)
大多数的远端(不是全部)支持服务器端复制。这个意味着,如果你像拷贝一个目录到另外一个,rclone并不会下载所有文件再重新上传;它将指示服务器将它们复制到位。比如:
将不会下载并重新上传将
oldbucket的内容拷贝到newbucket。在这种情况下,不支持服务器端复制的远端将下载并重新上传。服务器端拷贝被
sync和copy一起使用,使用-v标志时将在日志中进行标识。如果远程服务器不支持服务器端直接移动,那么move命令也可以使用它们。这是通过通知服务器端拷贝然后删除而完成的,比下载和重新上传要快得多。仅当远端(remote)名称相同时,才尝试服务器端拷贝。下面情况将无法使用服务器端拷贝:
- Author:zhuzi
- URL:/article/example-13
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
Relate Posts
.jpg?table=collection&id=15559529-ab3e-812c-8768-000b937dad10&t=15559529-ab3e-812c-8768-000b937dad10&width=800&cache=v2)







