Create (or Borrow) a Script

Once you've decided which sort of copy command you want to use, the next step is to wrap the command up in a text file, most likely with some other code to give it some basic intelligence, so that you can execute it simply by running the script.

A very basic backup script could be something as simple as this:

#!/bin/bash
cp -r /Users/joe /Volumes/Backup

This script begins with a line that specifies which shell to use (bash, in this case). It then uses the cp command to copy files; the -r flag (for "recursive") tells it to copy entire folders. The first argument (/Users/joe) is the source; the second (/Volumes/Backup) is the destination.

Suppose you named this script backup and stored it in the Applications folder, you ...

Get Take Control of Mac OS X Backups, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.