Linux rsync 错误代码的综合列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20737204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Comprehensive list of rsync error codes
提问by seebiscuit
I'm writing a script that does daily snapshots of users' home directories. First I do a dry run using:
我正在编写一个脚本,该脚本对用户的主目录进行每日快照。首先,我使用以下方法进行试运行:
rsync -azvrn --out-format="%M %f" source/dir dest/dir
and then the actual rsync operation (by removing the -n
option).
然后是实际的 rsync 操作(通过删除该-n
选项)。
I'm trying to parse the output of the dry run. Specifically, I'm interested in learning the exact cause of the rsync error (if one occurred). Does anyone know of
我正在尝试解析试运行的输出。具体来说,我有兴趣了解 rsync 错误的确切原因(如果发生了)。有谁知道
- The most common rsync errors and their codes?
- A link to a comprehensive rsync error code page?
- 最常见的 rsync 错误及其代码?
- 指向综合 rsync 错误代码页的链接?
Most importantly, rsync (at least on CentOs 5) does not return an error code. Rather it displays the errors internally and returns with 0. Like thus:
最重要的是,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]
Has anyone had to parse rsync errors and have a suggestion on how to store the rsync return state(s)? I believe, when transferring multiple files, that errors may be raised on a per file basis and are collected at the end as shown on the last line of code above.
有没有人必须解析 rsync 错误并对如何存储 rsync 返回状态提出建议?我相信,在传输多个文件时,错误可能会在每个文件的基础上引发,并在最后收集,如上面最后一行代码所示。
采纳答案by iandouglas
Per the rsync "man" page, here are the error codes it could return and what they mean. If you're scripting it in bash, you could look at $?
根据 rsync“手册”页面,这里是它可能返回的错误代码及其含义。如果你在 bash 中编写脚本,你可以看看$?
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
I've never seen a comprehensive "most common errors" list but I'm betting error code 1 would be at the top.
我从未见过全面的“最常见错误”列表,但我打赌错误代码 1 会排在最前面。