본문으로 건너뛰기

SSH를 이용해서 rsync 명령을 사용하는 방법은?

💡 요약 정리

  • rsync 명령은 ssh를 이용해 별도의 rsync 데몬 없이도 백업을 수행할 수 있습니다.
  • rsyncd.conf 파일 생성이나 rsync 데몬 실행 없이 가능하며,
  • -e ssh 옵션을 추가하면 됩니다.
  • master서버 또는 slave서버에서 모두 명령 수행이 가능합니다.
  • 각각의 예제 명령어를 문서에서 확인할 수 있습니다.

rsync 백업 시 rsync 데몬을 사용하지 않고, SSH를 사용하여 데이터를 백업할 수 있습니다.

이 경우 다음과 같은 방식으로 처리됩니다.

  • 별도의 rsyncd.conf 파일을 생성하지 않아도 됩니다.
  • rsync 데몬을 실행할 필요도 없습니다.
  • -e ssh 옵션을 추가해서 간단히 사용할 수 있습니다.

이 명령은 master 서버 또는 backup 서버 모두에서 수행 가능합니다.


1. master 서버에서 rsync 명령으로 백업

[root@localhost ~]# rsync -avzr --delete -e ssh /home/jook/public_html/ root@192.168.100.61:/backup/jook/
The authenticity of host '192.168.100.61 (192.168.100.61)' can't be established.
RSA key fingerprint is 4a:42:46:c9:55:48:63:08:a5:84:0a:69:d8:a6:47:0e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.61' (RSA) to the list of known hosts.
root@192.168.100.61's password:
sending incremental file list
sent 67 bytes  received 12 bytes  10.53 bytes/sec
total size is 0  speedup is 0.00
[root@localhost ~]#

2. slave 서버에서 rsync 명령으로 백업

[root@localhost ~]# rsync -avzr --delete -e ssh root@192.168.100.60:/home/jook/public_html/ /backup/jook/
root@192.168.100.60's password:
receiving incremental file list
sent 11 bytes  received 68 bytes  8.32 bytes/sec
total size is 0  speedup is 0.00
[root@localhost ~]#