Rsync is great for making sure that a destination directory is synchronised with a source directory. However, do you add a slash to the source and/or destination directory names, or do you not?
The answer is, it depends. Without a slash on the source directory means copy both the source directory, and the contents (recursively if specified) to the destination directory while adding a trailing slash means only copy the contents of the source directory, recursively if specified, to the destination. Easy?
If we take the following as the source directory:
|
|
|
|
The destination is an empty directory named test_backup.
No Slashes
The first test has no slashes on any of the directories.
|
|
|
|
You can see that the whole hierarchy of the testing directory has been recreated within the destination directory.
Slash on Destination Only
The second test, after clearing out the destination directory, adds a slash to the end of the destination directory.
|
|
|
|
So, there’s no difference there. A slash on the destination directory appears to have no effect.
Slash on Source Only
|
|
|
|
This is different. The contents of the source directory have been duplicated into the destination directory.
Slashes on Both
|
|
|
|
And this one again shows that having a slash on the destination directory has no effect.