Can I safely backup my system by simply tarring things?

Of course, the recommended method of backing up an OSX machine is to use Time Machine. But let's say that, for whatever reason, I'm deadset on doing it myself.

If I simply tar up things I care about (my user directory, /Applications, Application Support, Libraries etc), and later extract them to a fresh OSX install, will everything work? I know I have to use explicit flags to preserve ownership and permissions, but assuming I do that, does tar completely preserve all the metadata OSX wants like resource forks and all the rest of it?


Solution 1:

Time Machine would probably be easier and or better then using tar as there is no mention in the man page that it will preserve resource forks and HFS meta-data information. *See Edit below.

ditto does and more... From it's man page:

ditto will preserve resource forks and HFS meta-data information when copying unless instructed other- wise using −−norsrc . Similarly, ditto will preserve extended attributes and Access Control Lists (ACLs) unless −−noextattr or −−noacl is passed. DITTONORSRC can be set in the environment as an alias to −−norsrc −−noextattr −−noacl on the command line.

Edit: While the tar man page did not specifically mention "preserve resource forks and HFS meta-data information" like ditto did nonetheless I'd suggest testing tar and see if it will meet your needs. I just did a preliminary test on a modified folder that contains a customized image for the folder and it did archive the associated meta-data, at least some of it anyway. That is to say I didn't test against ditto for comparison nor does that folder have ACL's, etc.

Edit 2: Considering the comment you made as to why you wanted to use tar and after tests between ditto and tar I'd say tar is probably going to meet your needs. In either case I like redundancy and I do a Time Machine Backup as well as some other form of archival. I do a separate image of my Home folder every once in a while to a compressed .dmg file.

Solution 2:

There's also a command hdiutil which can be used to make a single dmg file from a directory, and the HFS flags are all preserved.