I want to copy what is different in dir 1 to dir 2 maintaining the structure, what is just different will be the content of each folder /logs/ content, if it's the same then just overwrite, if it doesn't exist, then copy.

I'm trying with rsync but it doesn't work, it just creates another dir named with source in destination.

Some photos (the structure, content, folder names, order, is the same, what just changes is the text files inside /logs/ inside each code-username folder).

            [![All code-username files in es51][1]][1]

As you can see rsync just creates the source folder in the destination, it's like a cp -r source destination, what I want is to overwrite logs so I have each logs files in each folder, maintaining the structure.

  • 1
    Please replace the screenshots with plain text. It's more legible, it's able to be parsed by search engines, and it saves space.
    – Sparhawk
    Aug 7, 2018 at 11:21

1 Answer 1


If you want to rsync the contents of a directory and not the top level directory you have to end your directory arguments to rsync with a /.


 $ rsync /path/to/copy/ /path/to/put

This will take the contents of /path/to/copy but not the top level directory copy and sync it to /path/to/put. You don't need to do this, but I like this notation better because it really communicates the intent to others:

 $ rsync /path/to/copy/ /path/to/put/.

That says to copy the contents of /path/to/copy and put it in directory /path/to/put/..

So in your screenshot example you'd do this:

$ screen -dmS Rsync \
  rsync --archive --progress /media/pi/copias/Tribal/ /media/pi/servidor/.
  • 1
    Thanks, now i think its working, 48 hours trying to solve these and what just a /. thanks really for your help you help me a lot dude.
    – Local Host
    Aug 7, 2018 at 11:53
  • @LocalHost - I've made the same mistake, glad to pay it forward 8-).
    – slm
    Aug 7, 2018 at 12:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .