I’m a Systems/Software Engineer in the San Francisco Bay Area. I moved from Columbus, Ohio in 2007 after getting a B.S. in Physics from the Ohio State University. I'm married, and we have dogs.

Under my github account (https://github.com/addumb): I open-sourced python-aliyun in 2014, I have an outdated python 2 project starter template at python-example, and I have a pretty handy “sshec2” command and some others in tools.

Linux tip 3 - rsync gotchas

October 22, 2009

description: rsync trailing slashes are tricky. Always use them for existing directories, always omit them to create new ones at the destination.

Use rsync a lot? Do you use it just infrequently enough to have to check the man page every time? Me too. I always have trouble with out it interprets trailing slashes on paths.

  • Copy entire directory to remote parent directory:
    rsync /path/without/slash host:/path/to/parent/with/slash/
    
  • Copy contents of one directory to another:
    rsync -r /path/to/directory/* host:/path/to/directory/
    
  • Copy a directory into a new directory on another host:
    rsync /path/without/slash host:/path/to/new/directory
    

One more thing, I almost always use -aP, but for some high-latency connections you’ll probably also want to pass -z for compressing the stream.


Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. :wq