Rsync Path Shenanigans

Published on 19th Jan, 2019 by Administrator

I love the tools that Andrew Trigdell has written. I used Samba for years at a razor-thin budget social services agency, and I use rsync *all the time*. But the way the paths work in rsync always made me just a touch crazy when I was getting started, as they're not 100% identical to Bash. It's now muscle memory, but I risk mis-remembering when reviewing a junior engineer's proposed change and need to look at my notes. So here's my old notes, annotated to for readability and removal of expletives. All examples below can be prefaced with an appropriate rsync invocation and the inevitable smorgasbord of command-line options. This copies the entire directory 'bar' to the current directory. `user@host:/foo/bar .` This copies everything in the 'bar' directory to the current directory except not the hidden files `user@host:/foo/bar/* .` This copies everything in the entire 'bar' directory to the current directory, *including hidden files*. `user@host:/foo/bar/ .` This copies the entire directory 'bar', into 'foefum', *as a sub-directory named bar inside 'foefum'*. `user@host:/foo/bar foefum` This copies everything in the entire 'bar' directory to the current directory, *including hidden files* into a new sub-directory named 'foefum'. `user@host:/foo/bar/ foefum` Don't get it wrong. And if you get it wrong and summon Cthulhu, well, that's not my fault.