Backups and Cloning

From OS X Scientific Computing

Jump to: navigation, search



The Complications of the HFS+ File System

There are two types of filesystem disk formats we need to worry about, HFS+, which is the default OS X filesystem format, and UFS, which is the "normal" unix file system format. All of the standard unix utilities were originally designed to cope with UFS. They will work on HFS+, but unless they are explicitly "resource-fork-aware" (as is the case with those distributed in 10.4.X and above), they will break what are called "resource forks" because this is a unique structure to HFS+. So, for example, if you back up or copy with normal unix utilities a carbon application or a file having an icon, you may find that it will break the application or make the icon disappear. In some cases, this could create a genuine problem. At the very least it will lead to annoyances like losing the information that tells OS X which application to use to open a particular file.

Resource Forks and Metadata

Some Unix utilities play nice

Apple's Time Machine

Time Machine does automatic hourly backups

As of 10.5, Apple comes with a free, incremental backup system called Time Machine. The GUI is a serious piece of eye-candy:


As Apple's own backup utility, it knows how to handle resource forks. One unusual feature is that it uses hard links to directories to create a browsable incrementally backed up file system.

The only additional requirement is a dedicated (usually external) hard drive. A 1TB drive is now comparatively inexpensive and will suit most people's needs.

The backup routine can be customized to omit directories on your hard drive. Omitting /sw might be a good idea for example, as the incremental changes would accumulate very rapidly, there is generally no need to save older increments, and the whole installation should be replaceable with relative ease.

A further description of Time Machine's features is available on Apple's website.

Time Machine Editor

It is hard to imagine that this won't be sufficient for most people's needs. However, one annoyance I find is that it wants to do incremental backups every single hour when it is activated, and currently there is not a convenient way to change this backup interval.

Fortunately, a free third-party application called TimeMachineEditor provides a simple interface that permits the user to customize the frequency of backups.


Carbon Copy Cloner

Before Time Machine appeared, this was my favorite GUI-based backup system. It is still quite useful, and especially so for making a clone of a drive. It's engine is based on a resource-respecting emulation of rsync, called psync, and Apple's nicely-named ditto. Newer version's of Apple's rsync now should be safe to use.

Carbon Copy Cloner is a donation-ware GUI wrapper for psync and ditto. It allows you to make a bootable clone of your startup disk and makes automated updates extremely straightforward and easy to implement. The author insists that academic users not pay for this.


Unix Approaches

Backing up HFS+ filesystems with resource forks

(This is a more compehensive backup procedure in that you can do it all this way).

If you want to back up OS X files, applications, etc, to another OS X HFS+ disk, either on your machine, or remotely, you can:

A. Use Time Machine Mount the other computer or external drive and manually drag and drop files in the finder window. This will give you exact copies of your files on the target backup HFS+ formatted disk.

B. Use OSX-specific copying programs like the newer cp, tar, mv, rsync, or the older CpMac, psync, or ditto, as described above. Each of these procedures will give you exact copies of your files on the target backup HFS+ formatted disk. psync allows you to do incremental backups, copying only what has changed between the source and target directories.

C. Use OSX-specific archiving software like hfspax or hfstar. These create a compressed archive of your files that you can copy and store on ANY unix disk and that can then be expanded on an HFS+ formatted disk.

D. Use Carbon Copy Cloner.

Backing up normal unix files

This is a more protable backup procedure that should be filesystem-independent.

If you want to back up "normal" unix files (i.e, most crystallographic softwware, input and output, all ascii text, everything in /sw and /usr/local), you can either use the above tools, or you can use the standard unix equivalents (cp, tar, etc.) that reside within (for example) fink. You can use these procedures to back up everything. In other words, you can't hurt a normal unix file by backing it up with all of your other OSX files. However, this may be overkill, so you might prefer to back up normal unix files using the normal procedures. The advantage of the latter is that you can then unpack and read these files on any unix file system. That is why I am including them both

Again, this procedure will only back up normal unix files correctly. It will not honor resource forks.

If, for example, you have installed fink, you will have a "normal" version of tar that resides in /sw/bin/tar.

The tar in /usr/bin/tar will respect resource forks, but if you are backing up something that you wish to unpack on (for example) a Linux system, you might want to strip off the resource forks. You can either explicitly omit all files of the form


or use /sw/bin/tar explicitly:

/sw/bin/tar  cvfz   foo.tar.gz  directory1  directory2 directory3

Fink in fact puts its own tar at the head of the path, so be careful to use the right version of tar for the right occasion. I usually alias tar to /usr/bin/tar, i.e,

alias tar=/usr/bin/tar

so that by default, I will be using a tar that respects resource forks. When in doubt, it is better to include them than to strip them off.

Personal tools