What the message looks like
rsync: [sender] send_files failed to open "/var/log/app/current.log": Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1338)Common causes
- The rsync user cannot read source files or directories.
- Files change during the run, such as logs, caches or database files.
- Attributes like ACLs or xattrs cannot be applied on the target.
- The target filesystem cannot store permissions or owners, for example FAT or NFS with
root_squash. - A file disappears between the file list and the transfer, common with rotated logs.
Check
- Exit code and statistics
rsync -a --stats src/ dst/ 2>&1 | tail -n 15; echo "exit=$?" - Show only the error lines
rsync -a src/ dst/ 2>&1 | grep -E 'rsync: |failed|Permission denied' | head -n 20 - Dry run without writing
rsync -an --itemize-changes src/ dst/ | head -n 20 - Check permissions along the path
namei -l /backup/data
Fix
- Read the individual error lines: code 23 is the summary, the reason is right above it.
- Check read permissions and run rsync as the right user instead of forcing root.
- For changing files, take a consistent database backup first or skip directories with
--exclude. - Only transfer attributes the target supports:
-awithout-AX, or use a suitable filesystem. - For backups, 23 is a failure even if almost everything was copied. Do not treat it as success.
Typical scenario
A nightly backup with rsync -a /home/ /mnt/nas/ to an SMB share ends with rsync error: some files/attrs were not transferred (see previous errors) (code 23). Before it come lines like rsync: chown ... failed: Operation not permitted and failed to open ... Permission denied. The target knows no Linux owners, and the run without root cannot see other users' files. First read the lines before the summary, not just the exit code.
FAQ
Can I ignore code 23?
Only if you know exactly which files are missing. --itemize-changes and the error lines show it; for backups 23 is a failure.
Why does it only happen on the second run?
Because files changed during the run or attributes could not be set on the target.
What causes lie behind code 23?
Mostly permission problems reading the source, failed attributes at the target, such as chown on SMB, NTFS or FAT, or file names invalid for the target system. For targets without Linux permissions, --no-perms --no-owner --no-group often helps instead of -a.
What is the difference between code 23 and code 24?
Code 24 reports that source files vanished during the run, typical for temporary files or logs. That is usually harmless. Code 23 means something could not be transferred or set, and should be checked in every case.
How do I catch the error in a cron job?
Write the output to a file with --log-file and evaluate the script's exit code. On a non-zero value, send a notification. A backup that silently skips files is more dangerous than one that fails loudly.