rsync

on

My files are archived to another machine with rsync. Using a command like:

$rsync -avh [from dir] [knilluz@server:/to dir]

There is only one annoying issue with this command. The trailing slash.

rsync -avh /home/knilluz/dirtobackup/ knilluz@zerver:/backup/xxx

will lead to another result than:

rsync -avh /home/knilluz/dirtobackup knilluz@zerver:/backup/xxx

In one case the name of the directory ‘dirtobackup’ will be included in the destination, in the other case only the files in the dirtobackup will be archived. Confusing. In this blog I will show the results of all combination of the trailing slash.

And the results are: the slash in the to dir is of no meaning. If the dir exists it will be used, if it not exists it will be created. But the slash in the from dir is very meaningfull: if used the data in the dir will be copied. if NO trailing slash is used, ALSO the dirname will be copied.

So if you sync with this command:

rsync -avh /home/knilluz/fotos knilluz@remote:/home/knilluz/fotos

at remote site the result will be /home/knilluz/fotos/fotos/[lots of jpg’s]

In this case a trailing slash should be used.

rsync-experiment