2013-12-23 6 views
15

사용자의 홈 디렉토리에 대한 일별 스냅 샷을 작성하는 스크립트를 작성하고 있습니다. 다음포괄적 인 rsync 오류 코드 목록

rsync -azvrn --out-format="%M %f" source/dir dest/dir 

및합니다 (-n 옵션을 제거하여) 실제 rsync를 작동 : 우선은 건조하여 실행을한다.

나는 드라이 런의 출력을 분석하려고합니다. 특히, rsync 오류의 정확한 원인을 학습하는 데 관심이 있습니다 (발생한 경우). 누구든지 알고 있습니까

  1. 가장 일반적인 rsync 오류 및 해당 코드는 무엇입니까?
  2. 포괄적 인 rsync 오류 코드 페이지에 대한 링크?

가장 중요한 것은 rsync (최소한 CentOS 5 이상)는 오류 코드를 반환하지 않습니다. 오히려 이렇게 같이 0과 내부 오류 및 반환을 표시

sending incremental file list 
rsync: link_stat "/data/users/gary/testdi" failed: No such file or directory (2) 

sent 18 bytes received 12 bytes 60.00 bytes/sec 
total size is 0 speedup is 0.00 (DRY RUN) 

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6] 

사람이 rsync와 오류를 구문 분석하고 rsync를 리턴 상태 (들)를 저장하는 방법에 대한 제안을 가지고 있었나요? 여러 파일을 전송할 때 파일 단위로 오류가 발생할 수 있으며 위 코드의 마지막 줄에 표시된 것처럼 끝에 오류가 수집 될 수 있습니다.

답변

28

rsync "man"페이지별로 반환 할 수있는 오류 코드와 그 의미는 다음과 같습니다. 당신이 떠들썩한 파티에서 스크립팅하는 경우, 당신은 내가 포괄적 인 "가장 일반적인 오류"목록을 본 적이 있지만 상단에있을 것입니다 오류 코드 1을 걸거야 $?

0  Success 
1  Syntax or usage error 
2  Protocol incompatibility 
3  Errors selecting input/output files, dirs 
4  Requested action not supported: an attempt was made to manipulate 64-bit 
     files on a platform that cannot support them; or an option was specified 
     that is supported by the client and not by the server. 
5  Error starting client-server protocol 
6  Daemon unable to append to log-file 
10  Error in socket I/O 
11  Error in file I/O 
12  Error in rsync protocol data stream 
13  Errors with program diagnostics 
14  Error in IPC code 
20  Received SIGUSR1 or SIGINT 
21  Some error returned by waitpid() 
22  Error allocating core memory buffers 
23  Partial transfer due to error 
24  Partial transfer due to vanished source files 
25  The --max-delete limit stopped deletions 
30  Timeout in data send/receive 
35  Timeout waiting for daemon connection 

볼 수 있었다.

+0

맨 페이지에이 목록이 있다는 것을 알지 못했습니다! 감사합니다. Btw, 파이썬에서 파싱 중입니다. 당신은 '$'의 파이썬과 동등한 것이 무엇인지 아십니까? – seebiscuit

+0

예, subprocess.call을 사용하는 경우이 페이지를 확인하십시오. http://www.python.org/doc//current/library/subprocess.html#replacing-os-system nutshell : 'return_code = subprocess .call (...)' – iandouglas

+0

'rsync'는 오류 코드를 쉘에 반환하는 것에 대해 우스운 일임을 알게되었습니다. 예를 들어 잘못된 소스 디렉토리를 입력했는데'rsync : link_stat "/ data/users/gary/testdi"실패 : 파일이나 디렉토리가 없습니다 (2)'와'rsync error : some main.c (1039) [보낸 사람 = 3.0.6]에서 파일/attrs가 전송되지 않았습니다 (이전 오류 참조) (코드 23). 그럼, $ 인쇄? 호출 직후 셸에서 0을 반환했습니다. – seebiscuit