document/文档/linux/rsync.md
2025-03-04 21:49:01 +08:00

28 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# rsync 服务器文件传输
## 安装
```sh
sudo apt-get install rsync
```
## 常用命令
```sh
# 从本地同步到远程服务器
rsync -avz /path/to/local/dir/ user@remote.server:/path/to/remote/dir/
# 从远程服务器同步到本地
rsync -avz user@remote.server:/path/to/remote/dir/ /path/to/local/dir/
#显示传输进度
rsync -avz --progress /home/user/project/ user@remote.server:/home/user/backup/
# 排除某些文件或目录 同步时排除某些文件或目录,可以使用 --exclude 选项:
rsync -avz --exclude 'node_modules' --exclude '*.log' /home/user/project/ user@remote.server:/home/user/backup/
# 使用 rsync 同步删除文件 在源位置删除的文件,也在目标位置删除,可以使用 --delete 选项
rsync -avz --delete /home/user/project/ user@remote.server:/home/user/backup/
```
## 常用选项
1. -a归档模式表示递归传输并保持所有文件属性。
2. -v详细模式显示传输过程中的详细信息。
3. -z压缩文件数据以减少传输量。
4. -P显示传输进度并自动重启传输中断的部分
rsync -avz /www/wwwroot/119.45.131.215_80/app/admin /www/wwwroot/testbaji.onelight.vip/app/admin