rsync multiple remote directories to local machine preserving directory paths

Directly from the rsync man page:

The syntax for requesting multiple files from a remote host is done
by specifying additional remote-host args in the same style as the 
first, or with the hostname omitted.  For instance, all these work:

    rsync -av host:file1 :file2 host:file{3,4} /dest/
    rsync -av host::modname/file{1,2} host::modname/file3 /dest/
    rsync -av host::modname/file1 ::modname/file{3,4}

This means your example should have a space added before the second path:

rsync -e ssh [email protected]:/path/to/file :/path/to/second/file/ /local/directory/

I'd suggest you first try it with the -n or --dry-run option, so you see what will be done, before the copy (and possible deletions) are actually performed.


just an actual example of @tonin. Download specific directories from live server

rsync -av [email protected]:/var/www/html/cls  \
:/var/www/html/index.php \
:/var/www/html/header.inc \
:/var/www/html/version.inc.php \
:/var/www/html/style.css \
:/var/www/html/accounts \
:/var/www/html/admin \
:/var/www/html/api \
:/var/www/html/config \
:/var/www/html/main \
:/var/www/html/reports .