/errors/rsync/some-files-vanished-before-they-could-be-transferred-code-24
rsync warning: some files vanished before they could be transferred (code 24)
- tool
- rsync
- exit code
- 24
- versions
- rsync 3.x
- os
- linux, macos
rsync warning: some files vanished before they could be transferred (code 24) means rsync listed a file when it scanned the source, and by the time it came to copy that file, the file was gone. rsync prints file has vanished: "PATH" for each one, finishes the rest of the transfer, and exits with code 24 (RERR_VANISHED). Everything that still existed was copied. For backups of live directories this is expected; treat 24 as a warning and exclude directories whose files come and go.
What the output looks like
The lines are built in rsync's flist.c and log.c; the file name is quoted, and the final line names the source file, line number, role and version of the rsync that reported it:
file has vanished: "/var/www/app/cache/session_8f3a.tmp"
rsync warning: some files vanished before they could be transferred (code 24) at main.c(N) [sender=3.x.y]main.c(N) and the version vary between builds. Because rsync sets exit code 23 (some files/attrs were not transferred) when there was also a real error, 24 alone means vanished files were the only problem.
Treat 24 as success in scripts
rsync -a --delete /var/www/ backup:/srv/backup/www/
status=$?
if [ "$status" -eq 0 ] || [ "$status" -eq 24 ]; then
echo "backup ok"
else
echo "rsync failed with exit code $status" >&2
exit "$status"
fiAvoid the warning
- Exclude short-lived files:
--exclude='tmp/' --exclude='cache/' --exclude='*.tmp'. - Copy from a snapshot: take an LVM, ZFS or Btrfs snapshot, rsync from the snapshot, then remove it. The source cannot change during the copy.
- Quiesce the application: stop or pause the service that writes to the directory for the duration of the backup.
--ignore-missing-args does not help here: it covers source arguments given on the command line that do not exist, not files that disappear during the transfer.