Intro
Files can be lost when your Mac’s internal storage develops a fault, gets corrupted, or if you accidentally trash a file. OS X’s Time Machine feature offers protection against such events by backing up new and modified files once an hour. All you need to provide is an external hard drive.
It won’t help recover files that are created and trashed within that interval, but multiple versions of other files on your Mac are preserved while there’s free space available. As it diminishes, the number of old versions is trimmed, but you can always connect a fresh drive.
In the long term, it’s worth complementing Time Machine with an off-site backup plan to protect against physical damage or theft of all your hardware. But for day-to-day mishaps, and even serious faults, Time Machine can quickly get you out of a sticky situation. Here’s how to set it up.
Read: Complete Guide to Time Machine
Step 1: Connect a drive

Attach an external drive to your Mac. A dialog might ask if you want to use the drive for backups. Press ‘Don’t use’ and open System Preferences — found in the Applications folder, and in the Apple menu at the top-left — to take a look at Time Machine’s detailed settings. Click Time Machine’s icon in the System group.
Step 2: Choose the drive

Press ‘Select Backup Disk…’ in Time Machine’s preferences pane to reveal a list of disks on which it can store backups. The list will include a Time Capsule if one is found on the local network. Select your external drive. Optionally, tick the box labeled ‘Encrypt backups’ for protection at the expense of some speed. Press ‘Use Disk’.
Step 3: Multiple Backups

Back in the main pane, the switch on the left will have moved to the On position. Switch it off while we look at advanced options. Mountain Lion allows backing up to more than one disk. Press ‘Select Disk…’ and the list is now split in two: a group for discs used for backing up, and others that are available.
Step 4: Choose a second drive

Select another disk and press ‘Use Disk’. Time Machine will ask if you want to use this disk for your backups exclusively or in addition to the previous one you selected. Choose ‘Use Both’. When a backup occurs, Time Machine will alternate between them, leaving one disk an hour behind the other, but giving added insurance should one drive fail.
Step 5: Back up at two sites

Using multiple drives helps with a MacBook that moves between locations. Time Machine backs up to whichever configured drive is available. If your Mac is damaged or lost in transit, its most recent contents will be preserved at your last location. Encryption can be set independently for each drive you use – handy for a portable drive carried on business trips.
Step 6: An eye on activity

With a drive configured, Time Machine’s pane lists the range of dates and times of the backups on each one. Below this information is a checkbox labeled ‘Show Time Machine in menu bar’. Leave it ticked to show a clock face-like icon at the right of the menu bar. It animates when a backup is in progress.
Step 7: Advanced options

Press the Options button to show a pane that appears allows items to be excluded from backups. Naturally, Time Machine’s backup drives are excluded, so other files put on them aren’t backed up. The Boot Camp (Windows) partition can’t be backed up either. Other external drives listed can be backed up by selecting them, then pressing the minus button below.
Step 8: Exclude items

To exclude items, click the plus button below, browse to and select an item, then click the Exclude button. Holding Cmd lets you select multiple items in the same location. Alternatively, drag items from a Finder window into the list. To exclude a volume’s contents, press Cmd+C in a Finder window and drag in the volume’s icon.
Step 9: Exclude system files

Time Machine backs up OS X, and provides a way to restore it in the event of a problematic software update or failed internal drive. If you use Carbon Copy Cloner to keep a bootable copy anyway, excluding the System folder (at the top of the startup disk) saves several gigabytes. When asked, exclude all other system files as well.
Step 10: Start the first backup

Now Time Machine is configured, press Save to go back to the its main pane. Ensure the switch is set to ‘On’, and a countdown to the first backup will begin. It might take several hours to complete the first backup, but later ones will be much quicker, as only changed and new files need to be copied.
Step 11: Subsequent backups

After the first backup is complete, subsequent backups take place at hourly intervals. You can check when the last one occurred by clicking Time Machine’s menu bar icon. From there, you can force an unscheduled backup by choosing ‘Back Up Now’. That’s a good idea if you’re about to install a software update, particularly one for OS X.
Step 12: Enter Time Machine

To recover a file, open a Finder window, click Time Machine’s menu bar icon and choose ‘Enter Time Machine’. The view changes to a stack of Finder windows going back in time. Use the arrows at its bottom-right to step back in time, or use the timeline at the bottom-right to quickly go to a time longer ago.
Step 13: Find a file

The Finder window in the centre of the screen is used to browse your Mac as it was at the selected point in time. Type in the search bar to quickly find things, and add rules to narrow the search, just like on the Desktop. Select a file and press the spacebar to check you’ve found the right version.
Step 14: Recover a file

Recover a file by selecting it, then press the Restore button at the bottom-right. To put it somewhere besides its original location, click the Action button (cog) and choose its Restore option. That button also lets you delete one or all versions of a file from Time Machine, freeing space if older versions of a large document aren’t needed.
Step 15: Restore your system

To roll back your system to an earlier state, hold Cmd-R at the startup chime (Lion, Mountain Lion) or insert the install DVD and hold C (Leopard, Snow Leopard). Choose Restore from Time Machine Backup from the menu that appears (in the Utilities menu in Leopard and Snow Leopard), choose Restore From Time Machine Backup and follow the prompts.