nojeans@xudegloss:~$ mkdir rsync
nojeans@xudegloss:~$ cd rsync/
nojeans@xudegloss:~/rsync$ mkdir src
nojeans@xudegloss:~/rsync$ mkdir dst
nojeans@xudegloss:~/rsync$ ls
dst src
## src 디렉토리에 파일 만들어서 dst 디렉토리 안에 "동기화 진행 -> 복제 진행" ##
nojeans@xudegloss:~/rsync$ cd src
nojeans@xudegloss:~/rsync/src$ touch test{1..10}
nojeans@xudegloss:~/rsync/src$ ls -l
total 0
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test1
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test10
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test2
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test3
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test4
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test5
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test6
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test7
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test8
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test9
nojeans@xudegloss:~/rsync/src$ cd ..
## src 안에 있는 모든 파일들을 dst에 동기화 ##
**## archive 모드 >> 기본적으로 특정 디렉토리 내 모든 것을 복사 또는 변경 사항만 전송,
혹은 파일 속성 및 권한 관련한 정보까지 모두 전송**
nojeans@xudegloss:~/rsync$ rsync -a src/ dst
nojeans@xudegloss:~/rsync$ ls -l dst
total 0
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test1
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test10
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test2
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test3
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test4
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test5
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test6
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test7
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test8
-rw-rw-r-- 1 nojeans nojeans 0 Apr 16 23:52 test9
>> if "rsync -a src dst" 입력 시 **디렉토리 dst에 src 디렉토리 자체가 동기화
>> 좋은 점은 한 쪽에서 파일 삭제 혹은 권한 변경 시, 동기화 명령 내린 후 확인하면
동기화로 인하여 다른 쪽에서도 파일도 수정되는 것을 확인할 수 있음
>> 전송 대상이 있는 경우에만 고려하기 때문에, 굉장히 효율적**
<aside> ✅ 1) sync 2) Remote + sync 3) 동기화 ⇒ 수정 사항까지도 모두 동기화 (파일 제거 혹은 권한 변경 등) 4) archive 모드 ⇒ 모든 부분들을 “동기화” 하거나 “효율적으로 관리”하는 모드
</aside>
## ~/rsync/src/ 아래 있는 파일을 사용자 계정 & IP 주소인 ~/rsync/dst 디렉토리 아래에
동기화 작업 진행
rsync -azP ~/rsync/src/ [파일 받고자 하는 사용자 계정]@[IP 주소]:~/rsync/dst
# z는 압축하여 전송한다는 의미 => 효율적으로 사용할 수 있도록 만듦
# P는 전송되는 상황을 "progress bar"로 보여줌