rsync 작업목표
1. 10.10.10.2 서버의 /home 디렉토리를 10.10.10.1 클라이언트의 /home/backup으로 복사
2. crontab 에 등록해서 매주 1회 정기적으로 기존파일 삭제 후, 복사
rsync 설정
1. 클라이언트(10.10.10.1) ssh key파일 생성(rsync 시 비밀번호 입력생략위해)
1) # ssh-keygen -t rsa -b 2048
엔터키 3~4번 정도 후 /root/.ssh/id_rsa.pub, id_rsa 파일 생성
2) 생성된 id_rsa.pub 파일을 서버(10.10.10.2)의 /root/.ssh/authorized_keys 로 이름변경해서 전송
2. 서버(10.10.10.2) sshd 설정변경
Authorized_key 주석해제
[root@divweb2 .ssh]# cat /etc/ssh/sshd_config | grep -r Authorized
AuthorizedKeysFile .ssh/authorized_keys
3. 서버(10.10.10.2) sshd restart
# /etc/rc.d/init.d/sshd restart
4. 클라이언트(10.10.10.1) crontab 에 아래의 명령어 스케줄 지정
rsync -avP --delete --stats -l -t -e ssh root@10.10.10.2:/home/ /home/backup
--delete 옵션을 사용하면 변경된 사항 체크 후, 변경된 부분만 복사함
receiving file list ...
160523 files to consider
test/0 files...
test/test1
12 100% 0.00kB/s 0:00:00
rsync[8444] (receiver) heap statistics:
arena: 32744216 (bytes from sbrk)
ordblks: 13637 (chunks not in use)
smblks: 1
hblks: 1 (chunks from mmap)
hblkhd: 1028096 (bytes from mmap)
usmblks: 0
fsmblks: 48
uordblks: 17520944 (bytes used)
fordblks: 15223272 (bytes free)
keepcost: 10392 (bytes in releasable chunk)
Number of files: 160523
Number of files transferred: 1
Total file size: 14983392981 bytes
Total transferred file size: 12 bytes
Literal data: 12 bytes
Matched data: 0 bytes
File list size: 3715662
Total bytes written: 38
Total bytes read: 3715730
wrote 38 bytes read 3715730 bytes 675594.18 bytes/sec
total size is 14983392981 speedup is 4032.38
참고자료
https://www.joinc.co.kr/w/Site/Tip/Rsync

