Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rsync multiple remote directories to local machine preserving directory paths

Tags:

rsync

Would I be able to use rsync as such:

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

or would i have to do something else?

like image 625
FilBot3 Avatar asked Apr 04 '13 17:04

FilBot3


People also ask

Can rsync copy directories?

Rsync is a command-line tool in Linux that is used to copy files from a source location to a destination location. You can copy files, directories, and entire file system and keep in sync the files between different directories. It does more than just copying the files.

Do I need rsync on both machines?

The rsync utility must be installed on both the client and server machine before getting started. Rsync has two modes: local and remote. If both machines are on the same network, the local mode is used. This uses minimal transfer security and can rapidly perform transfers and synchronization over LAN.

Does rsync create destination directory?

Rsync creates a directory with the same name inside of destination directory - Server Fault. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.

Is rsync recursive?

To sync the contents of dir1 to dir2 on the same system, you will run rsync and use the -r flag, which stands for “recursive” and is necessary for directory syncing: rsync -r dir1/ dir2.


1 Answers

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.

like image 144
Læti Avatar answered Oct 22 '22 04:10

Læti