rsync로 대용량 파일을 전송할때 오류 발생되는 경우 - rsync: writefd_unbuffered failed to write 4 bytes to socket

ERP 디비 백업 파일을 rsync 로 백업을 하는데 아래와 같은 오류가 발생 했다.


0000/00/00 00:00:00 [3248] connect from UNKNOWN (xxx.xxx.xxx.xxx)

0000/00/00 00:00:00 [3248] rsync on erpbackup/backup_* from unknown (xxx.xxx.xxx.xxx)

0000/00/00 00:00:00 [3248] building file list

0000/00/00 00:00:00 [3248] rsync: writefd_unbuffered failed to write 4 bytes to socket [sender]: Connection reset by peer (104)

0000/00/00 00:00:00 [3248] rsync error: error in rsync protocol data stream (code 12) at io.c(1539) [sender=3.0.7]


읽어 보면 

1. 알수 없는서버(xxx.xxx.xxx.xxx) 에서 접속시도 했고 

2. rsync를 실행 해서 백업 파일을 요청했고

4. 파일 목록을 작성했다.

5. 그런데 버퍼링 되지 않은채 소켓에 4바이트를 쓰기가 실패 해서 연결을 리셋 했다.

(rsync: writefd_unbuffered failed to write 4 bytes to socket [sender]: Connection reset by peer (104))

인데...


구글링을 해보니 대용량 파일을 전송시 발생 할 수 있다 한다.

이럴 경우 클라이언트 즉 백업서버에서 rsync 호출시 "--temp-dir=/tmp" 옵션을 추가하면 된다.

rsync -azvrt --temp-dir=/tmp --delete xxx.xxx.xxx.xxx::erpbackup/backupfile backupdir;

.

.

.

그런데 또  같은 현상이 발생 했다.

그래서...

--bwlimit=2500 옵션을 추가 했다.

--bwlimit : 대역폭, 초당 전송 속도을 한정하는 옵션으로, 서비스중인 서버에 무리를 줄일 수 있다.


추가로.

--log-file="/home/backup/log/rsync.log" : rsync 로그생성 옵션


최종적으로

rsync -azvrt --temp-dir=/tmp --bwlimit=2500 --log-file="logfilepath" --delete xxx.xxx.xxx.xxx::erpbackup/backupfile backupdir;