2010/06/28

Recipes for tm-diff (Time Machine difference)

A few recipes for using the tm-diff.sh script that I posted earlier (see link for details):

  • Ignore errors/warnings (ex: "Permission denied"):
    tm-diff.sh folder1 folder2 2> /dev/null

  • Find all files, regardless of their privileges/permissions:
    sudo tm-diff.sh folder1 folder2

  • Display disk usage, in "human-readable" sizes (ex: KB, MB, GB...):
    tm-diff.sh folder1 folder2 | while read f; do du -h "$f"; done

  • Display disk usage, with a grand total at the end (sizes in KB):
    tm-diff.sh folder1 folder2 | while read f; do du -k "$f"; done | awk '{ sum += $1; print; } END { print sum; }'

  • Display the largest 50 files (sizes in MB):
    tm-diff.sh folder1 folder2 | while read f; do du -m "$f"; done | sort -n | head -50

  • Display the smallest 100 files (sizes in KB):
    tm-diff.sh folder1 folder2 | while read f; do du -k "$f"; done | sort -rn | head -100

  • Display a full listing (with mode/privileges, owner, group...):
    tm-diff.sh folder1 folder2 | while read f; do ls -l -h "$f"; done


Notes:
  1. This presumes you've set your PATH so it'll find the tm-diff.sh script. (Or use its full path.)

  2. In the commands above, "folder1" and "folder2" of course represent the paths to the two Time Machine backup folders to compare; they'll look something like:
    /VOLUMENAME/Backups.backupdb/USERNAME/2009-07-20-091153

  3. The script explicitly searches for regular files only; no directories or other special files.

  4. I use a read loop, since this will get the full path, including "special" characters like spaces and double-quotes.

  5. Sizes are in the classic style ("as God intended"): KB = 1024 bytes; MB = 1024 KB; GB = 1024 MB ...

  6. Most Time Machine backups contain tens of thousands of files, so these will take awhile. The ones that sort will display no files, until all of them have been found, to be sorted - so they will seem to take even longer.

No comments: