3

For copying large files (and/or large quantities of files), especially across disks, I prefer to avoid using the Finder as it often fails with some meaningless error message and/or complaint about permissions.

Instead I have been looking at using rsync -- or, more specifically, the latest version of rsync available from Homebrew, which, as of today, is:

rsync  version 3.1.1  protocol version 31

Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, symtimes, no prealloc, file-flags

(Those are the default capabilities that Homebrew uses.)

The problem is that rsync is hopelessly complex, and I'm never sure if I am using the proper arguments, or if there are others that I should be using:

rsync \
    --8-bit-output \
    --acls \
    --backup \
    --devices \
    --exclude='.DS_Store' \
    --executability \
    --group \
    --human-readable \
    --inplace \
    --itemize-changes \
    --owner \
    --perms \
    --progress \
    --prune-empty-dirs \
    --recursive \
    --safe-links \
    --specials \
    --stats \
    --times \
    --update \
    --verbose \
    --xattrs \
    'foo' /path/to/destination/

Args I'm not sure if I should be using or not, mostly because I'm not 100% sure what they do:

  • (one of the other options for links instead of '--safe-links')
  • --relative
  • --sparse
  • --partial

Any other suggestions?

  • Have you considered using ditto instead? – njboot Jul 9 '14 at 20:43
2

Unless you have some specific needs, I would throw out most of those options and keep it simple: rysnc -aEv (on the default OS X version) or rsync -aXv (on the Homebrew version).

Options

  • -a is archive mode, which essentially means preserve the metadata (timestamps, permissions, etc.) and do a recursive copy. This is what you want for your standard backup or copy operations.

  • -E/-X preserves extended attributes (a.k.a. resource forks). In the past the built-in rsync version had special functionality to cover HFS+ quirks in this regard, but newer default versions of rsync may be improved in that regard now. I would lean towards using the built-in version unless you have a specific reason not to.

  • -v is the verbose option, and simply makes it easier to track what's going on if you're running this in a Terminal window. If it's going to be running in a script, you can remove it.

Unless you know you need them, you can safely ignore most of those options you've got already. Some are duplicated by the archive command, and others (like --inplace, which can slow things down and leave the filesystem in an inconsistent state) are only necessary for specific edge cases. Do yourself a favour and keep things simple — if you run into specific issues with the options I've listed, perhaps enumerate those (in a separate question if need be).

As an aside, running into problems copying via Finder is a bit of a red flag IMO. While it may not always be as fast as some options, it shouldn't be throwing error messages. You may want to verify/repair your disk in Disk Utility.

  • 1
    Part of my desire is to learn more about these various options and where I might want to use them. For example, some of them seem to have to do with just reporting what was done after it’s all completed. As for Finder, I know what you mean but in this case it’s usually something like a folder inside a .dvdmedia bundle which has weird permissions or something like that. There are tons of websites in Google which all seem to repeat the man rsync info but no pages with more in-depth/readable explanations of what they do and when they should/shouldn’t be used. – TJ Luoma Jul 9 '14 at 19:40
  • Extended Attributes is not the same as resource forks. – Max Ried Jul 9 '14 at 20:27
  • @MaxRied true. It would be more accurate to say that extended attributes are a more general concept, of which resource forks are a Mac/HFS+ specific implementation thereof. But for Mac purposes they can be more or less interchangeable. – robmathers Jul 9 '14 at 20:46
  • From my understanding resforks are more actual file content while xattrs are more anotations. But yes, they can emulate each other. – Max Ried Jul 9 '14 at 20:48
-1

you could use ditto which is a more advanced cp and was created by Apple.

  • Could you show an example how it's used ? – Jash Jacob Oct 12 '14 at 1:59
  • Apple has developed its own (better) implementation of cp. This command, called "ditto," not only copies the files from the source directory to the destination directory, creating the destination directory if it doesn't already exist; but will also merge the contents of the source directory with the destination directory if it does exist. ditto ~/Documents/MyFolder ~/Desktop/MyNewFolder @JashJacob – Ginfuru Oct 23 '14 at 2:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .