Suppose you want to backup or transfer files from one remote server to another you can do it simply by using scp. Let me brief you about SCP.
SCP stands for secure copy (remote file copy program).
scp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1). scp will ask for passwords or passphrases if they are needed for authentication.
COPY CODE SNIPPETFile names may contain a user and host specification to indicate that the file is to be copied to/from that host. Local file names can be made explicit using absolute or relative pathnames to avoid scp treating file names containing ‘:’ as host specifiers. Copies between two remote hosts are also permitted.
Enough of theory stuff, let’s see the example:
Suppose you want to transfer files/folder from 12.34.56.789 to 88.12.98.980. Therefore first login to the server 88.12.98.980 and run the following command as follows:-
scp -r root@12.34.56.789:/var/www/html.zip /var/www/html/
where
-r = Recursively copy entire directories. Note that scp follows sym‐bolic links encountered in the tree traversal.
root = User of that machine.
12.34.56.789 = Ip of the server where the data exists.
/var/www/html.zip = File that resides on 12.34.56.789 server.(from where u will transfer)
/var/www/html = Directory of 88.12.98.980 server where the files will be copied.
For the server which doesn’t have the default port 22 run the following command:
scp -r -P1234 root@88.12.98.980:/var/www/html.zip /var/www/html/
Done Enjoy!!?