I recently bought a new [amazon_link id=”B005T3GRNW” target=”_blank” ]1TB hard drive[/amazon_link] to replace my measly 250GB media drive. I needed to clone the contents of the small drive onto the new drive.
You could just open up two Finder windows and just drag the folders but that’s tedious and if you accidentally click cancel during the copy process your kind of stuck.
This is a great example of a time to use the command line.
Apple bundles a couple of UNIX utilities that allow you to copy files around. We’re going to briefly explore three.
The first – CP is the traditional copy program.
Copying files with the cp command is simple. First, launch Terminal (in your /Applications/Utilities folder). Then, use the following syntax to create your command:cp source destination
For example, to copy a file named MyFile.rtf from your Desktop folder to your Documents folder, you would type in the following command in Terminal and then press Return:cp ~/Desktop/MyFile.rtf ~/Documents
I tend to use cp when I’m copying a single file at a time.
The second program is ditto. Ditto preserves permissions when run as root and preserves resource forks by default. Ditto can be used to clone your system with the following step:
sudo ditto -X / /Volumes/Backup
Finally, there is rsync. The really cool thing about rsync is that it allows you to resume a copy that is interrupted. It’s also really good if you need to keep files in sync.
If you’ve never used rsync before then today is going to be a great day for you. Firstly, rsync is not new it’s been around for quite a while and chances are you’ve already used it without realising. One of the things I use it for most is to sync directories on your local machine (useful for creating backups to external devices) or you can sync with a remote connection. A Practical Guide to Using rsync – Created by Pete
In the end, I used rsync because I wanted to make sure if the copy was interrupted I didn’t have to start over.
I did it with this command.
sudo rsync -vaE --progress /Volumes/SourceName /Volumes/DestinationName
And my drive was backed up before I knew it.
CP, RSYNC and Ditto are all really powerful UNIX utilities to move files around on your Mac. If you’ve been afraid of using the command line you’re really missing out on some cool tools.