tmutil compare gives differences between two backups. But I wonder how do I sort the output by file size? With GNU
sort, there is the
--human-numeric-sort option for this, but the
sort which is part of macOS doesn't support this. So how can I sort the result by file size?
To slightly improve upon Andreas' answer, you can sort without having to cut out the beginning part that indicates if it's an addition, removal, or change:
tmutil compare backup-1 backup-2 | grep "^[\!+-]" | sort -h -k 2
(The grep part filters out the summary lines)
The names "backup-1/2" are the full paths to two timestamped backup directories, eg
/Volumes/Backup/Backups.backupdb/Computer-Name/2020-09-10-123220. You can also pass in sub-folders if you just want to compare those, though I think they need to both point to the same path within their respective backups.
Or if you want to filter by just additions (
+) and modifications (
!) without removals (
-), for example:
tmutil compare backup-1 backup-2 | grep "^[\!+]" | sort -h -k 2
Note that the "!" needs to be escapes as it's got special meaning in bash.