I tend to use rsync when others would typically use a simple cp for copying files. A few reasons:
- It can be canceled in the middle, and resumed later.
- It can show a progress bar that (while not perfect) is great for large files or lots of files.
- It will only copy the changed files and won’t clobber already existing directories of files at the target.
rsync is available on Linux, Mac, and there’s a binary somewhere on teh intarwebs for Windows.
To use, you almost always want to pass the
-a flag, which stands for “archive” – basically a convenience flag for
-t (timestamps), and a few others. I can’t think of a time I haven’t used
-a when using rsync.
Following that, basic usage looks like this:
The other thing to remember when using rsync is that it’s picky with slashes; if you put a trailing lash on a path, then rsync takes that to mean you want to copy the contents of that path. If, on the other hand, you leave off the slash, it will copy the path and its contents. A few examples will help:
1 2 3 4 5
Some other handy arguments:
So, to put it all together:
And, better yet, rsync can work over ssh (if it’s installed on both hosts). Just put an ssh host on the front of either path:
So, there you have it. rsync can do tons more stuff, but this is a great start. If this is all you learn of rsync, you will be that much better off.