rsync
파일·디렉터리
쓰는 꼴
rsync -av [source]/ [dest]/두 디렉터리의 다른 점만 옮깁니다. 원본 끝에 슬래시를 붙이면 그 안의 것을 뜻하고, 빼면 디렉터리가 한 겹 더 깊이 들어갑니다.
자주 쓰는 옵션
| 옵션 | 뜻 |
|---|---|
| -a | Archive: recursive, keeping permissions, times and symlinks |
| -v | List what is transferred |
| -z | Compress while it travels |
| -P | Show progress and keep partial files so a transfer can resume |
| --delete | Remove files in the destination that are gone from the source |
| -n | Dry run: print what would happen and change nothing |
| --exclude | Skip paths matching a pattern |
| -e | Choose the remote shell, as in -e "ssh -p 2222" |
예시
rsync -avP big.iso server:/data/Copies with progress, and can resume later.
rsync -av --delete site/ /backup/site/Makes the backup an exact mirror.
rsync -avn src/ dst/Dry run first; nothing is written.
옮기고 지우고 찾는 것들. 되돌릴 수 없는 명령이 섞여 있어 -i를 붙이는 습관이 손을 구합니다.
읽는 방법
- 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
- 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
- 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.
자주 묻는 것
Q. rsync은 무엇을 하나요?
두 디렉터리의 다른 점만 옮깁니다. 원본 끝에 슬래시를 붙이면 그 안의 것을 뜻하고, 빼면 디렉터리가 한 겹 더 깊이 들어갑니다.
Q. 어떻게 치나요?
rsync -av [source]/ [dest]/ — 대괄호는 생략할 수 있는 자리입니다.
Q. 옵션은 몇 개나 자주 쓰나요?
여기 정리한 것은 8개입니다. 전체 목록은 man rsync에 있습니다. 이 명령은 파일·디렉터리 갈래입니다.
같이 보는 명령
man 페이지: man rsync