Monday, July 8, 2024

Rsync and the Trailing or Omitted Slash

I learned this recently, and it can be a real headache if one isn't aware of it. Rsync copies source FILES into the destination when a trailing slash is used on source. It copies source FOLDER and FILES into destination when trailing slash is OMITTED.

So...

rsync -avh /home/bobby/Documents/ bobby@192.168.0.10:/mnt/300gb/

results in all the files and subdirectories of /home/bobby/Documents/ being copied to /mnt/300gb/.


But if you omit the trailing slash on the source, like this

rsync -avh /home/bobby/Documents bobby@192.168.0.10:/mnt/300gb/

you get all the files and subdirectories of /home/bobby/Documents being copied to /mnt/300gb/Documents/.

REMEMBER THIS.

No comments:

Post a Comment