July 24, 2009
Lilliput
Until recently I used rsync+hfsmode to back up my Mac to a Linux box. I stopped only because I needed the features of rsync 3, but that lost me the ability to back up extended attributes in AppleDouble format, which can reside on a plain, non-HFS+ filesystem. Anyway, it turns out rsync+hfsmode had been creating corrupt AppleDouble files for three years—ever since I moved from PPC to Intel. So much for testing your backups.
Briefly, it's an endian issue. Use htonl(), guys! So, I wrote a simple script, adouble-fix.pl to detect and repair broken AppleDouble files created by rsync+hfsmode. It's limited to files which contain only Finder Info and resource forks, but this is exactly what the --hfs-mode=appledouble option produces.
$ time find 4 -name "._*" -type f -print0 | xargs -0 adouble-fix.pl -n -q Dry-run finished. 1878 files seen, 1852 fixed, 26 skipped, 0 errors. Dry-run finished. 1895 files seen, 1641 fixed, 254 skipped, 0 errors. Dry-run finished. 1511 files seen, 1301 fixed, 210 skipped, 0 errors. real 0m23.586s user 0m1.460s sys 0m1.450s $ time find 4 -name "._*" -type f -print0 | xargs -0 adouble-fix.pl -q Finished. 1878 files seen, 1852 fixed, 26 skipped, 0 errors. Finished. 1895 files seen, 1641 fixed, 254 skipped, 0 errors. Finished. 1511 files seen, 1301 fixed, 210 skipped, 0 errors. real 0m3.555s user 0m2.240s sys 0m0.980s $ time find 4 -name "._*" -type f -print0 | xargs -0 adouble-fix.pl -q Finished. 1878 files seen, 0 fixed, 1878 skipped, 0 errors. Finished. 1895 files seen, 0 fixed, 1895 skipped, 0 errors. Finished. 1511 files seen, 0 fixed, 1511 skipped, 0 errors. real 0m1.069s user 0m0.820s sys 0m0.400s