rsync is the tool when it comes to shuffling around data reliably. Be it on the local machine or between remote servers. The usual use case is: Make sure this folder has the same contents of that folder. This would do:

$ rsync -av /path/to/src /path/to/dst

The -v instructs rsync to be verbose and -a (“archive”) enables a couple of options you’d want by default (copy files recursively, keep timestamps & permissions, etc.).

Now, rsync is able to sync the contents two folders or to sync one folder into another. One has to be very careful with that. Depending on whether a trailing slash is provided for the source directory, rsync will either sync the contents of src & dst or sync src into dst. Let’s see what this means exactly.

$ ls /path/to/src # src contains 3 files
a  b  c
$ rsync -av --dry-run /path/to/src/ /path/to/dst # trailing slash
sending incremental file list
created directory /path/to/dst # rsync creates the target folder
./ # rsync copies the files found inside src into dst
a
b
c

sent 104 bytes  received 28 bytes  264.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
$ rsync -av --dry-run /path/to/src /path/to/dst # no trailing slash
sending incremental file list
created directory /path/to/dst # rsync creates the target folder
src/ # rsync copies src into dst!
src/a
src/b
src/c

sent 118 bytes  received 29 bytes  294.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)

See? Usually, the first execution is what you want: One expects rsync to sync the two given folders. You need to provide a trailing slash after src in order to achieve this. Or: No trailing whitespace at after src but the provided target directory is one level up, i.e. /path/to instead of /path/to/dst. The advantage of using the trailing slash is that the two folders (source & destination) do not have to share the same name as shown in the example above. Note that it doesn’t make a difference if dst doesn’t exist (rsync creates it if needed) or whether you provide a trailing whitespace after dst or not.

By the way: When running rsync interactively, the --progress command line switch is quite handy. It shows - for each file - the transmitted file size and the estimated remaining transmission time.