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

tar + SSH Pipe

~10 min · tar, ssh, pipe, many-small-files

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

rsync 없거나 너무 느릴 때

두 시나리오에서 tar | ssh 가 rsync 보다 빠름:

  1. 수천 개 작은 파일. rsync 의 파일별 메타데이터 overhead 가 병목 됨. tar 가 모든 거 한 연속 archive 로 stream.
  2. 원격 쪽에 rsync 안 깔림 (요즘 드문데 가끔).

패턴이 Unix 고전 — tar 가 stdout 에 archive 만들고, pipe 가 ssh 한테 먹임, ssh 가 원격에 tar 돌려 추출. 중간 파일 없음, 임시 디스크 공간 없음, 그냥 stream.

Code

tar pipe 통한 push, pull·bash
# Push: local → remote
tar czf - /path/to/source | ssh host 'tar xzf - -C /destination/'

# Pull: remote → local
ssh host 'tar czf - /path/to/source' | tar xzf - -C /local/dest/

# Add progress with pv (`brew install pv`)
tar cf - /source | pv | ssh host 'tar xf - -C /dest/'

# Skip compression on fast LAN, use a fast cipher to reduce CPU
tar cf - /source | ssh -c aes128-gcm@openssh.com host 'tar xf - -C /dest/'

External links

Exercise

작은 파일 많은 디렉토리 골라 (node_modules 또는 Python venv, scratch path 에 복사). 두 접근 시간 재 — time rsync -az source/ host:/tmp/x/ vs time (tar cf - source | ssh host 'tar xf - -C /tmp/y'). 100k+ 작은 파일의 Gigabit LAN 에서 tar 가 보통 2–5× 이김.

Progress

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

댓글 0

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

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