Feeds:
Posts
Comments

Archive for July 10th, 2018

by Tom Nelson

You may not have heard of rsync; it’s a file transfer and synchronization program that’s often used to create elaborate and complex backup systems.

Written for Unix operating systems, rsync is included with the Mac and can be accessed directly from Terminal, or used within a number of scripting languages.

The rsync program has a number of features that make it a good candidate for building local, as well as remote, backup, archiving, and synchronization systems. It can also be used for basic file copying, and for maintaining file synchronization between one or more folders, either locally or with a remote system (think cloud-based storage, as an example).

In this Rocket Yard Guide, we’re going to concentrate on using rsync locally. If you wish to use rsync with a remote system, you’ll need to ensure that both the local system and the remote system have rsync installed.

If you’re looking for a copy of rsync to install on a system other than a Mac, or you’re just interested in discovering more about this versatile app, you can check out the rsync website.

Before we get into details about using rsync on the Mac, a note about versions. The version of rsync that’s distributed with the Mac tends to lag behind the current version available on the rsync website. The Mac version has been at 2.6.9 for a number of years, while the current version is at 3.1.3 (as of January, 2018). You should have no problems using the older Mac version with remote platforms that have one of the newer versions installed, but going the other direction could have unexpected results. Always check version compatibility when using rsync with remote systems.

Using Rsync
The Terminal app is used to invoke rsync and its various commands. If you’re new to using the Terminal app, check out the Rocket Yard series Tech 101: Introduction to the Mac’s Terminal App.

Rsync uses a simple structure for issuing commands:

rsync -options theSourceDirectory theDestinationDirectory
While the number of options can get long, the format is always the same; the rsync command followed by any optional switches, then the source directory followed by the destination directory.

The rsync -r command copied all the files on my Desktop to my USB flash drive named DocsBackup. Notice that the time stamp on all the copied files is set to the current date. Screen shot © Coyote Moon, Inc.

Let’s look at a basic rsync command that will copy a directory and all sub-directories it may contain. To tell rsync we want all the files and folders, including everything in subdirectories, we include the -r option. In the Terminal app, enter:

rsync -r /Users/tnelson/Desktop /Volumes/DocsBackup

(Replace tnelson with your user name, and DocsBackup with your desired target for the copy.)

In this example, my messy Desktop folderand its contents will be copied to a USB flash drivenamed DocsBackup. After the command is executed by hitting the return or enter key, the DocsBackup flash drive will have a new folder named Desktop, with all of my Desktop content.

If you want to copy only the contents of the Desktop, and not the parent folder named Desktop, you would add a forward slash after the directory named Desktop, like this:

rsync -r /Users/tnelson/Desktop/ /Volumes/DocsBackup

Read more on Rocket Yard, The MacSales.com Blog

Read Full Post »