We backup a set of virtual machines to an external USB drive using rsync -a
. The source directory is 145G as reported by du -sh
, but the target is reporting 181G.
The two file systems are ext3
and the block size is the same, so can someone explain what the discrepancy is?
Others already told about sparse files, but there is another thing: hard links. Hard links – multiple names for the file (and space on the disk) are often used on system partitions (e.g. for multiple shell commands implemented in the same binary) and they are not handled specially by rsync with the '-a' option only. So, e.g. a file with four hard links will be stored as four separate files.
Try using
rsync -aH
.As Dennis mentioned, it seems to be a sparse file issue. An example of that can be:
As you can see
du
reports how many blocks are actually used, whilels
shows how big the file is supposed to be.With the rsync script, are you deleting the items that exist on the destination and are no longer on the target? If you're looking to have an identical copy on both sides, you would need a "--delete" flag in your rsync routine.
"rsync -a --delete /source/ /destination/"
You can also inject "-n and -P" into the string to provide a dry-run and progress indicator, respectively, to show you what would happen with the "--delete" option.