Is rsync ~/foo target/foo the same as rsync ~/foo/ target/foo/
rsync
Is rsync ~/foo target/foo the same as Is rsync ~/foo/ target/foo/?
Best Answer
No. The trailing slash on the source directory determines whether the directory and its contents or just its contents will be copied. And that's all that matters.
Given:
a/b
a/c
Then:
$ rsync a/ d/
$ ls d
b
c
But:
$ rsync a d/
$ ls d
a
The trailing slash on the destination, on the other hand, doesn't matter.
The fact that your example already has a directory in the destination with the same name as the source directory is not really important...target/foo is always destination. In the examples above just replace a with ~/foo and d with target/foo and it works the same...
If you need to copy into a directory without write permission, add --inplace to command options. This is sometimes cheaper that it doesn't create a temporary copy, but during updating the file is in inconsistent state.
On the question why it doesn't check own rights beforehand: it could miss some additional specifics as extended access ACLs, so rsync doesn't believe into standard 3*3+3 scheme. OTOH this intentional policy doesn't make any real difference in result - anyway file isn't updated.
Ok /var/www/tmp/test//./saved_images/2013-07-07 is the same as /var/www/tmp/test/saved_images/2013-07-07.
Double / are ignored you can type ls //// and it is the same as ls /.
The dot . is the same directory it is in.
So ls /. shows the same output as ls / and so /var/www/tmp/test/. points to the directory /var/www/tmp/test/.
So rsync just takes the current directory it is in, in you case var/www/tmp/test/ (at least when your path starts with a .).
Then its adds an extra / so it can make sure that the path it definitely has a / add the end.
In the last step its adds the part you gave it, here ./saved_images/$(date +%Y-%m-%d)/$(date +%Y-%m-%d_%H-%M).jpg
The error you are seeing is that the directory /var/www/tmp/test/saved_images/ is not there and rsync will not create it, because it seams that rsync only creates one directory.
Edit
Maybe for your problem you should just use a script with
Best Answer
No. The trailing slash on the source directory determines whether the directory and its contents or just its contents will be copied. And that's all that matters.
Given:
Then:
But:
The trailing slash on the destination, on the other hand, doesn't matter.
The fact that your example already has a directory in the destination with the same name as the source directory is not really important...
target/foo
is always destination. In the examples above just replacea
with~/foo
andd
withtarget/foo
and it works the same......and...