Rsync - transfer files across servers

I. Introduction

To cooperate with each other, students need to use rsync to transmit data across servers, and to sort out the problems encountered during the period.

2. Common grammar and problems

1. rsync transfer data

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

E.g:

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

After the transfer is successful, the following prompt will appear:

2. Configure Rsync

The rsync related configuration is in the /etc/rsyncd.conf folder, which requires root privileges to modify its content.

sudo su - root

target_path is the directory where rsync receives files, and uid and gid are the transmission users that you are allowed to receive. If they can be passed in by default, just delete the two configurations of uid and gid. If they correspond to the above example, both uid and gid are csdn_group.

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

3. Transmission exception

The following error may be reported during transfer: rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c

This error is due to the permission of the receiving directory. Open the $target_path file permission in the above configuration to receive the file normally:

chmod -R 777 $target_path

After the repair is successful, you can receive files whose group is nobody, and process them normally:

3. Summary

In addition to rsync, nc can also be used to transfer files between servers. Refer to:  Shell - nc to transfer data across servers .

Guess you like

Origin blog.csdn.net/BIT_666/article/details/124036361