Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote Linux server to remote linux server dir copy. How? [closed]

People also ask

How do I copy a directory to a remote server in Linux?

In order to copy directory on Linux to remote location, you can execute the “scp” command with the “-r” option for recursive followed by the directory to be copied and the destination folder. As an example, let's say that we want to copy the “/etc” directory to a backup server located at 192.168.

How copy files from remote server to remote server?

You can use SecureShell (SSH) or Remote Sync (Rsync) to transfer files to a remote server. Secure Copy (SCP) uses SSH to copy only the files or directories that you select. On first use, Rsync copies all files and directories and then it copies only the files and directories that you have changed.

How do I copy files from one Linux remote to another?

In Unix, you can use SCP (the scp command) to securely copy files and directories between remote hosts without starting an FTP session or logging into the remote systems explicitly. The scp command uses SSH to transfer data, so it requires a password or passphrase for authentication.

How do I copy a directory to a local remote?

Copy or Download a File From Remote to Local Using SCP SCP syntax is pretty simple. Just invoke SCP followed by the remote username, @, the IP address or host, colon, and the path to the file. If not specified, the default path is the remote user's home directory.


There are two ways I usually do this, both use ssh:

scp -r sourcedir/ [email protected]:/dest/dir/

or, the more robust and faster (in terms of transfer speed) method:

rsync -auv -e ssh --progress sourcedir/ [email protected]:/dest/dir/

Read the man pages for each command if you want more details about how they work.


I would modify a previously suggested reply:

rsync -avlzp /path/to/sfolder [email protected]:/path/to/remote/dfolder

as follows:

-a (for archive) implies -rlptgoD so the l and p above are superfluous. I also like to include -H, which copies hard links. It is not part of -a by default because it's expensive. So now we have this:

rsync -aHvz /path/to/sfolder [email protected]:/path/to/remote/dfolder

You also have to be careful about trailing slashes. You probably want

rsync -aHvz /path/to/sfolder/ [email protected]:/path/to/remote/dfolder

if the desire is for the contents of the source "sfolder" to appear in the destination "dfolder". Without the trailing slash, an "sfolder" subdirectory would be created in the destination "dfolder".


rsync -avlzp /path/to/folder [email protected]:/path/to/remote/folder


scp -r <directory> <username>@<targethost>:<targetdir>

Log in to one machine

$ scp -r /path/to/top/directory user@server:/path/to/copy


Use rsync so that you can continue if the connection gets broken. And if something changes you can copy them much faster too!

Rsync works with SSH so your copy operation is secure.


Try unison if the task is recurring. http://www.cis.upenn.edu/~bcpierce/unison/