使用rsync做系统全备份时,/mnt下部分文件夹被无理由忽略求助
Great question—this is a common gotcha with rsync's filesystem traversal behavior, and I’ve run into it myself before. Let’s break down exactly what’s happening here:
The Main Culprit: The -x (--one-file-system) Flag
You’re using the -x option in your command, which tells rsync to stay strictly within the source filesystem (in your case, your root / partition). Any folders under /mnt that are mounted from other filesystems (like your NTFS /mnt/other_folder) are treated as separate, disconnected filesystems. So rsync will copy the empty /mnt/other_folder directory entry (since it’s part of the root filesystem) but won’t traverse into the mounted partition itself to copy its contents.
That’s why those folders appear "ignored"—rsync isn’t skipping them on purpose, it’s just following the -x rule you set.
How to Fix It
Option 1: Remove -x to Include All Mounted Filesystems
If you want to backup every mounted filesystem under / (minus the backup target), simply drop the -x flag. This lets rsync cross filesystem boundaries and copy contents from all mounted partitions:
rsync --stats --delete -avqhHAX --exclude '/mnt/rsync_backup' / /mnt/rsync_backup
Quick note: Be careful with this—this will include every mounted device (USB drives, network shares, etc.) unless you add additional --exclude rules for paths you don’t want to backup.
Option 2: Add Specific /mnt Folders as Separate Sources
If you want to keep -x (to only backup your root filesystem’s native files) but still include /mnt/other_folder, add it as a separate source argument. rsync treats each source independently, so it will backup the root filesystem (staying within its bounds) and then separately copy all contents from /mnt/other_folder:
rsync --stats --delete -avqhHAX --exclude '/mnt/rsync_backup' / /mnt/other_folder /mnt/rsync_backup
This is my preferred approach because it explicitly targets the mounted partition you care about without pulling in other unexpected mounts.
Option 3: Dry-Run First to Verify
Before running the actual backup, use the -n (dry-run) flag to preview what rsync will copy. This helps you confirm your /mnt/other_folder contents are included before making permanent changes:
rsync --stats --delete -avqhHAXn --exclude '/mnt/rsync_backup' / /mnt/other_folder /mnt/rsync_backup
Look for lines referencing files in /mnt/other_folder to ensure they’re being picked up correctly.
内容的提问来源于stack exchange,提问作者ThePhi

