Rsync - 跨服务器传送文件

一.引言

同学之间互相协作需要使用 rsync 跨服务器传送数据,期间遇到的问题做一下整理。

二.常见语法与问题

1. rsync 传输数据

rsync -avz --progress file 账户@ip::个人账户

例如:

rsync -avz --progress test.log [email protected]::BIT_666

传送成功后会有如下提示 :

2.配置 Rsync

rsync 相关配置在 /etc/rsyncd.conf 文件夹下,需要 root 权限才可以修改其内容。

sudo su - root

target_path 为 rsync 接收文件目录,uid 和 gid 为允许你接收的传送用户,如果默认均可传入,将 uid,gid 两项配置删除即可,如果对应上述示例,uid 和 gid 均为 csdn_group。

# BIT_666
[BIT_666]
path = $target_path
read only = no
uid = group
gid = group

3.传输异常

传输时可能会报如下错误 : rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c

该报错是因为对应接收目录权限问,将上述配置中的 $target_path 文件权限打开即可正常接收文件:

chmod -R 777 $target_path

修复成功后,可以接受到 group 为 nobody 的文件,正常处理即可 :

三.总结

除了 rsync 外,服务器之间传输文件也可以使用 nc,相关使用方法参考: Shell - nc 跨服务器传输数据

猜你喜欢

转载自blog.csdn.net/BIT_666/article/details/124036361
今日推荐