Programing

`scp`와`rsync`는 어떻게 다릅니 까?

lottogame 2020. 5. 5. 19:33
반응형

`scp`와`rsync`는 어떻게 다릅니 까?


Ghost 블로깅 설정 에 관한 기사에 따르면 scp내 로컬 시스템에서 원격 서버로 복사하는 데 사용 됩니다.

scp -r ghost-0.3 root@*your-server-ip*:~/

그러나 Railscast 339 : Chef Solo Basicsscp반대 방향 (원격 서버에서 로컬 컴퓨터로)으로 복사하는 데 사용 합니다.

scp -r root@178.xxx.xxx.xxx:/var/chef .

같은 Railscast에서 저자는 파일을 원격 서버에 복사하려고 할 때 (첫 번째 예와 같은 방향으로) 다음을 사용합니다 rsync.

rsync -r . root@178.xxx.xxx.xxx:/var/chef

양방향으로 복사 할 rsync경우 명령을 사용하는 이유는 무엇 scp입니까? scp와는 어떻게 다릅니 rsync까?


이러한 도구의 주요 차이점은 파일을 복사하는 방법입니다.

scp기본적으로 소스 파일을 읽고 대상에 씁니다. 로컬 또는 네트워크를 통해 일반 선형 복사를 수행합니다.

rsync또한 로컬 또는 네트워크를 통해 파일을 복사합니다. 그러나 특수 델타 전송 알고리즘 과 몇 가지 최적화를 사용하여 작업을 훨씬 빠르게 수행합니다. 전화를 고려하십시오.

rsync A host:B
  • rsyncAB 의 파일 크기와 수정 타임 스탬프를 확인하고 일치하는 경우 추가 처리를 건너 뜁니다.

  • 대상 파일 B가 이미 존재하는 경우 델타 전송 알고리즘은 AB의 차이 만 유선으로 전송합니다.

  • rsync임시 파일에 데이터를 쓸 것입니다 T , 다음 대상 파일 교체 B를 함께 T 사용하고있는 프로세스 업데이트보기 "원자"하기 위해 B를 .

그들 사이의 또 다른 차이점은 호출에 관한 것입니다. rsync다양한 명령 행 옵션이있어 사용자가 동작을 미세 조정할 수 있습니다. 복잡한 필터 규칙을 지원하고 배치 모드로 실행하고 데몬 모드 등에 scp는 스위치가 거의 없습니다.

요약하면 scp일상적인 작업에 사용하십시오. 대화식 쉘에서 가끔 입력하는 명령. 사용하기가 더 쉬우 며,이 경우 rsync최적화가 도움이되지 않습니다.

작업과 같은 반복 cron작업에는을 사용하십시오 rsync. 언급했듯이 여러 번 호출하면 이미 전송 된 데이터를 활용하여 매우 빠르게 수행하고 자원을 절약합니다. 네트워크를 통해 두 디렉토리를 동기화하는 훌륭한 도구입니다.

또한 큰 파일을 다룰 때는 옵션 rsync과 함께 사용 하십시오 -P. 전송이 중단 된 경우 명령을 다시 발행하여 중지 된 위치에서 다시 시작할 수 있습니다. Sid Kshatriya의 답변을 참조하십시오 .


rysnc는 느리고 신뢰할 수없는 연결에서 실행하는 데 유용 할 수 있습니다. 따라서 큰 파일 중간에 다운로드가 중단되면 rysnc는 다시 호출 할 때 중단 된 지점부터 계속할 수 있습니다.

사용하다 rsync -vP username@host:/path/to/file .

-P 옵션은 부분적으로 다운로드 된 파일을 유지하고 진행률을 보여줍니다.

평소대로 확인 man rsync


다른 매개 변수의 차이 흑백 scp 및 rsync

1. 대기 시간에 따른 성능

  • scp : scp는 상대적으로 덜 최적화되고 속도가 빠릅니다.

  • rsync : rsync는 비교적 최적화되고 속도가 빠릅니다.

https://www.disk91.com/2014/technology/networks/compare-performance-of-different-file-transfer-protocol-over-latency/

2. 방해 취급

  • scp : scp 명령 줄 도구가 손실 된 네트워크 연결에서 중단 된 다운로드를 재개 할 수 없음

  • rsync: 위의 rsync 세션 자체가 중단되면 동일한 명령을 입력하여 원하는만큼 세션을 재개 할 수 있습니다. rsync는 중단 된 위치에서 전송을 자동으로 다시 시작합니다.

http://ask.xmodulo.com/resume-large-scp-file-transfer-linux.html

3. 명령 예

scp

$ scp source_file_path destination_file_path

rsync

$ cd /path/to/directory/of/partially_downloaded_file
$ rsync -P --rsh=ssh userid@remotehost.com:bigdata.tgz ./bigdata.tgz 

-P옵션은 --partial --progressrsync와 부분적으로 다운로드 된 파일을 사용할 수 있도록 하는 것과 동일 합니다. --rsh=ssh옵션은 rsync에게 ssh를 원격 쉘로 사용하도록 지시합니다.

4. 보안 :

scp가 더 안전합니다. rsync --rsh=sshscp만큼 안전하게 만들기 위해 사용해야 합니다.

더 알고 싶은 사람 문서 :

performance chart


There's a distinction to me that scp is always encrypted with ssh (secure shell), while rsync isn't necessarily encrypted. More specifically, rsync doesn't perform any encryption by itself; it's still capable of using other mechanisms (ssh for example) to perform encryption.

In addition to security, encryption also has a major impact on your transfer speed, as well as the CPU overhead. (My experience is that rsync can be significantly faster than scp.)

Check out this post for when rsync has encryption on.


One major feature of rsync over scp (beside the delta algorithm and encryption if used w/ ssh) is that it automatically verifies if the transferred file has been transferred correctly. Scp will not do that, which occasionally might result in corruption when transferring larger files. So in general rsync is a copy with guarantee.

Centos manpages mention this the end of the --checksum option description:

Note that rsync always verifies that each transferred file was correctly reconstructed on the receiving side by checking a whole-file checksum that is generated as the file is transferred, but that automatic after-the-transfer verification has nothing to do with this option’s before-the-transfer “Does this file need to be updated?” check.


실제 상황에서 생각하는 것이 좋습니다. 우리 팀에서는 rsync -aP클러스터의 잘못된 cassandra 호스트를 교체하는 데 사용 합니다. 우리는 scp (느리게 진행하지 않고 진행 보존) 로이 작업을 수행 할 수 없습니다.


scp하나의 파일에 가장 적합 합니다.
또는tar 리소스가 적은 소스 코드 트리 ( : 이미지, sqlite ) 와 같은 소규모 데이터 세트에 대한 압축 및 조합 .


그러나 더 많은 양을 다루기 시작할 때 다음과 같이 말합니다.

  • 미디어 폴더 (40GB)
  • 데이터베이스 백업 (28GB)
  • mp3 라이브러리 (100GB)

그것은 구축 비실용적 우편 /의 tar.gz 로 전송하는 파일 scp를 받는 수행을이 시점에서를 물리적 호스팅 서버의 한계.

As an exercise, you can do some gymnastics like piping tar into ssh and redirecting the results into a remote file. (saving the need to build a swap or temporary clone aka zip or tar.gz)

However,

rsync simplify's this process and allows you to transfer data without consuming any additional disc space.

Also,

Continuous (cron?) updates use minimal changes vs full cloned copies speed up large data migrations over time.

tl;dr
scp == small scale (with room to build compressed files on the same drive)
rsync == large scale (with the necessity to backup large data and no room left)

참고URL : https://stackoverflow.com/questions/20244585/how-does-scp-differ-from-rsync

반응형