补充对于 pattern 的说明.

Signed-off-by: rick.chan <chenyang@autoai.com>
This commit is contained in:
rick.chan 2021-01-27 11:38:34 +08:00
parent 980af60229
commit 16bfb97c0d
1 changed files with 15 additions and 4 deletions

View File

@ -50,19 +50,30 @@ rsync -avzzrlP <src> <dst>
远程拷贝:
```bash
rsync -avzzrlP <file> <usrname>@<IP>:<path & name>
rsync -avzzrlP <src> <usrname>@<IP>:<path & name>
# 或
rsync -avzzrlP <usrname>@<IP>:<path & name> <file>
rsync -avzzrlP <usrname>@<IP>:<path & name> <dest>
# 或
rsync -avzzrlP -e 'ssh -p <port>' <usrname>@<IP>:<path & name> <file>
rsync -avzzrlP -e 'ssh -p <port>' <usrname>@<IP>:<path & name> <dest>
```
排除文件或目录:
```bash
rsync -avzzrlP <usrname>@<IP>:<path & name> --exclude <exclude file1> --exclude <exclude fileN> <file>
rsync -arzHlgopP <usrname>@<IP>:<path & name> --exclude <pattern1> --exclude <patternN> <dest>
```
注意,在排除文件或目录时,所有符合 pattern 规则的文件/目录都将被排除。例如根目录下和谋子文件夹下均有名为 exec 的文件/文件夹:
```bash
# 排除全部名为 exec 文件和文件夹
rsync -arzHlgopP --exclude exec <src> <dest>
# 只排除 <src>/exec 文件/文件夹
rsync -arzHlgopP --exclude /exec <src> <dest>
# 只排除 <src>/subdir/exec 文件/文件夹
rsync -arzHlgopP --exclude /subdir/exec <src> <dest>
``
同步后删除源文件,相当于移动文件操作(不影响目录):
```bash