rsync exit codes: 1, 2, 3, 5, 10, 11, 12, 23, 24, 30, 35 and 255 explained
- tool
- rsync
- versions
- rsync 3.x
- os
- linux, macos
rsync exits with 0 on success and with a specific code for each kind of failure. The codes that appear most are 23 (some files or attributes were not transferred), 24 (source files vanished during the transfer), 12 (protocol data stream error, usually the remote side failed to start), and 255 (unexplained error), usually the exit status of a failed SSH connection passed through. When rsync fails it prints rsync error: MESSAGE (code N); the table lists the code, the man page meaning and the message from rsync's source.
| Code | Meaning (man page) | Message printed by rsync |
|---|---|---|
| 0 | Success | (none) |
| 1 | Syntax or usage error | syntax or usage error |
| 2 | Protocol incompatibility | protocol incompatibility |
| 3 | Errors selecting input/output files, directories | errors selecting input/output files, dirs |
| 4 | Requested action not supported | requested action not supported |
| 5 | Error starting client-server protocol | error starting client-server protocol |
| 10 | Error in socket I/O | error in socket IO |
| 11 | Error in file I/O | error in file IO |
| 12 | Error in rsync protocol data stream | error in rsync protocol data stream |
| 13 | Errors with program diagnostics | errors with program diagnostics |
| 14 | Error in IPC code | error in IPC code |
| 15 | Sibling process crashed | sibling process crashed |
| 16 | Sibling process was killed by a signal | sibling process terminated abnormally |
| 19 | Received SIGUSR1 | received SIGUSR1 |
| 20 | Received SIGINT, SIGTERM, or SIGHUP | received SIGINT, SIGTERM, or SIGHUP |
| 21 | Some error returned by waitpid() | waitpid() failed |
| 22 | Error allocating core memory buffers | error allocating core memory buffers |
| 23 | Partial transfer due to error | some files/attrs were not transferred (see previous errors) |
| 24 | Partial transfer due to vanished source files | some files vanished before they could be transferred (a warning) |
| 25 | The --max-delete limit stopped deletions | the --max-delete limit stopped deletions |
| 30 | Timeout in data send/receive | timeout in data send/receive |
| 35 | Timeout waiting for daemon connection | timeout waiting for daemon connection |
Codes from the remote shell
rsync's source also names codes for failures of the remote shell command it starts (SSH by default). They are not in the man page list; unexplained error is what rsync prints for any code it has no name for:
| Code | Message | Typical cause |
|---|---|---|
| 124 | remote shell failed | The remote shell command exited with status 255 |
| 125 | remote shell killed | The remote shell was killed by a signal |
| 126 | remote command could not be run | The remote shell or --rsync-path is not executable |
| 127 | remote command not found | A command was not found: the remote shell program, or rsync on the remote host |
| 255 | unexplained error | Usually passed through from ssh, which exits 255 when it cannot connect or authenticate |
Handle codes in a backup script
rsync -a --delete /srv/data/ backup:/backups/data/
case $? in
0) echo "ok" ;;
24) echo "ok, some files vanished during the copy" ;;
23) echo "partial: check the rsync: lines above" >&2; exit 23 ;;
*) echo "rsync failed" >&2; exit 1 ;;
esacTreat 24 as success for live directories (logs, caches, mail spools) where files are deleted while rsync runs. Do not ignore 23 by default: it hides permission problems that leave files out of the backup.