Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy a directory from local machine to remote machine

Tags:

scp

ssh

rsync

I am using ssh to connect to a remote machine.

Is there a way i can copy an entire directory from a local machine to the remote machine?

I found this link to do it the other way round i.e copying from remote machine to local machine.

like image 805
nish Avatar asked Jul 24 '13 07:07

nish


People also ask

How copy file from local system to remote system?

To copy files from a local system to a remote server or remote server to a local system, we can use the command 'scp' . 'scp' stands for 'secure copy' and it is a command used for copying files through the terminal. We can use 'scp' in Linux, Windows, and Mac.

How do I copy a directory from one host to another in Linux?

In order to copy a directory on Linux, you have to execute the “cp” command with the “-R” option for recursive and specify the source and destination directories to be copied. As an example, let's say that you want to copy the “/etc” directory into a backup folder named “/etc_backup”.


2 Answers

Easiest way is scp

scp -r /path/to/local/storage [email protected]:/path/to/copy 

rsync is best for when you want to update versions where it has been previously copied.

If that doesn't work, rerun with -v and see what the error is.

like image 58
Oliver Matthews Avatar answered Sep 28 '22 07:09

Oliver Matthews


It is very easy with rsync as well:

rsync /path/to/local/storage [email protected]:/path/to/copy 

I recommend the usage of rsync over scp, because it is highly likely that you will one day need a feature that rsync offers and then you benefit from your experience with the tool.

like image 27
mnagel Avatar answered Sep 28 '22 07:09

mnagel