Home » Questions » Computers [ Ask a new question ]

Can I use ditto on OS X to sync two folders on the same machine?

Can I use ditto on OS X to sync two folders on the same machine?

Is it possible to use the command line utility ditto to keep two folders in sync on a single OS X machine? In other words, does ditto copy only changed files from the source, and delete removed files from the target?

Asked by: Guest | Views: 377
Total answers/comments: 2
Guest [Entry]

"No, ditto does not copy just the changed files. You would be better off using rsync for this. Bombich, the makers of Carbon Copy Cloner, have a great article on their site about different tools.

About ditto:

Ditto is a command-line utility that ships with Mac OS X. 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

About rsync:

rsync can be used to make a bootable clone as well. In addition to basic file copying, rsync also offers the ability to synchronize the source and target volumes -- it can copy only the items that have changed, thus subsequent clones, or backups, are much faster. The syntax is pretty easy:

sudo rsync -xrlptgoEv --progress --delete / /Volumes/Backup

However, I would highly recommend reading their detailed rsync document and upgrade to rsync 3.0.7 (I do it using MacPorts).

EDIT: OS X rsync 3.0.7 and metadata

To preserve metadata after installing the latest rsync, use the following command:

rsync -aNHAXx --protect-args --fileflags --force-change

This is from the bombich.com article. All these options may not always be needed, but this can be used to back up an entire hard drive as an example. That article also has a section on backup fidelity where they report the results from the backup bouncer test suite for rsync with the above options.

As an aside, to ensure that your files are being backed up properly, whichever method you use, the backup bouncer suite is very handy."
Guest [Entry]

rsync syncs one way. if you want two way sync, use unison.