C.W.K.
Stream
Lesson 05 of 12 · published

rsync over SSH (와 trailing slash)

~15 min · rsync, ssh, trailing-slash

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

같은 구문, SSH transport

rsync 가 원격 전송에 디폴트로 SSH 사용 — 같은 키, 같은 agent, 같은 ~/.ssh/config. 원격 쪽엔 rsync 설치만 필요, 거의 항상 깔려 있음. -e 로 SSH 옵션 통과 가능.

Trailing slash — rsync 혼란의 #1 원인

이 단일 규칙이 다른 어떤 거보다 더 많은 rsync 슬픔 야기:

  • rsync -av project/ dest/project/내용dest/ 안으로 복사.
  • rsync -av project dest/디렉토리 자체dest/ 안으로, 결과적으로 dest/project/.

project/ 의 trailing slash 는 "~의 내용" 의미 — shell glob project/* 같은데 dotfile 포함. Trailing slash 없음 = "전체로서의 이 디렉토리".

의심 들면 --dry-run 먼저.

Code

Push, pull, slash·bash
# Push: laptop → office
rsync -avz --progress ./project/ office:/home/you_username/project/

# Pull: office → laptop
rsync -avz --progress office:/home/you_username/project/ ./project/

# Specify SSH options (e.g. non-default port — though ~/.ssh/config is cleaner)
rsync -avz -e "ssh -p 2222" ./files/ host:/dest/

# Trailing slash demonstration
# WITH slash on source — copies CONTENTS
rsync -av project/ host:/dest/    # → /dest/file1, /dest/file2

# WITHOUT slash — copies the DIRECTORY itself
rsync -av project host:/dest/     # → /dest/project/file1, /dest/project/file2

External links

Exercise

테스트 path 에서 rsync -avn project/ /tmp/x/rsync -avn project /tmp/x/ 둘 다 (dry-run 주목) 돌려서 나열된 path 비교. 첫 번째 /tmp/x/foo, 두 번째 /tmp/x/project/foo. 그게 원하는 근육 기억 — slash 느껴, 절대 추측 X.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.