forked from tldr-pages/tldr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,37 @@ | ||
# rsync | ||
|
||
> 一种快速,通用,远程(和本地)文件复制工具。 | ||
> 一种快速,通用,远程(和本地)文件复制工具,默认使用 SSH。 | ||
> 如果要指定远程路径,请使用 `user@host:path/to/file_or_directory`. | ||
> 更多信息:<https://download.samba.org/pub/rsync/rsync.1>. | ||
- 从本地传输文件到远程主机: | ||
- 复制文件: | ||
|
||
`rsync {{path/to/local_file}} {{remote_host}}:{{path/to/remote_directory}}` | ||
`rsync {{path/to/source}} {{path/to/destination}}` | ||
|
||
- 从远程主机传输文件到本地: | ||
- 使用归档模式递归拷贝文件,并保留所有属性,不解析软链接: | ||
|
||
`rsync {{remote_host}}:{{path/to/remote_file}} {{path/to/local_directory}}` | ||
`rsync --archive {{path/to/source}} {{path/to/destination}}` | ||
|
||
- 将本地文件以归档模式并保留几乎所有属性,同时使用压缩功能传输到远程主机,并以人类可读方式输出详细信息和进度条: | ||
- 将文件以归档模式并保留几乎所有属性进行传输,并以人类可读方式输出详细信息和进度条,中断时保留部分信息: | ||
|
||
`rsync --archive --compress --verbose --human-readable --progress {{path/to/local_file}} {{remote_host}}:{{path/to/remote_directory}}` | ||
`rsync --compress --verbose --human-readable --partial --progress {{path/to/source}} {{path/to/destination}}` | ||
|
||
- 将远程主机目录上的所有文件,以递归模式传输到本地: | ||
- 以递归模式传输文件: | ||
|
||
`rsync --recursive {{remote_host}}:{{path/to/remote_directory}} {{path/to/local_directory}}` | ||
`rsync --recursive {{path/to/source}} {{path/to/destination}}` | ||
|
||
- 将远程主机该目录下的所有内容(不包含该目录),以递归方式传输到本地: | ||
- 将目录下的所有内容(不包含该目录),以递归方式传输: | ||
|
||
`rsync --recursive {{remote_host}}:{{path/to/remote_directory}}/ {{path/to/local_directory}}` | ||
`rsync --recursive {{path/to/source}}/ {{path/to/destination}}` | ||
|
||
- 递归方式传输目录,保留几乎所有属性,解析软连接,并忽略已传输的文件: | ||
- 归档方式传输目录,保留几乎所有属性,解析软连接,并忽略已传输的文件: | ||
|
||
`rsync --recursive --archive --update --copy-links {{remote_host}}:{{path/to/remote_file}} {{path/to/local_directory}}` | ||
`rsync --archive --update --copy-links {{path/to/source}} {{path/to/destination}}` | ||
|
||
- 指定本地和远程之间通信方式: | ||
- 传输目录到运行 `rsyncd` 的远端,并删除目标目录中源目录中不存在的文件: | ||
|
||
`rsync --rsh ssh {{remote_host}}:{{path/to/remote_file}} {{path/to/local_file}}` | ||
`rsync --recursive --delete rsync://{{host}}:{{path/to/source}} {{path/to/destination}}` | ||
|
||
- 指定本地和远程之间通信方式,使用指定端口,并显示进度条: | ||
|
||
`rsync --rsh 'ssh -p {{port}}' --progress {{remote_host}}:{{path/to/remote_file}} {{path/to/local_file}}` | ||
`rsync --rsh 'ssh -p {{port}}' --info=progress2 {{path/to/source}} {{path/to/destination}}` |