Wednesday, April 29, 2015

How to copy files/folders from a server to another server using SSH

I bought a new server for my programming site ifelse.tv, the server company who was renting me their servers has promised to partition my server in a way I could have 2TB of data storage.  I only had 1TB of data storage. I messaged them and they broke the news, they made a mistake and they need to re-format and repartition the server.



I have had uploaded already 150GB of video files, but I wasn't ready to give them up. I wanted a fast, quick and efficient solution.

The quickest and cheapest solution was to copy the 150GB of video files to another server, then add them back when they fix your server.

Both servers had a 100Mbps unmetered internet. That would make on average 14MB/sec. Not bad for 150GB of content files.

The only question was how to do it? Google helped me find my solution and this is how I did it.

1. Login to the server which has files you need backup via SSH. It doesn't matter if you have root access or not:























2. Execute this command (some changes need to be made):
scp -r --ignore-existing /home/admin/domains/s1.ifelse.tv/public_html/ifelse george@5.199.168.114:/home/george/ifelse


scp (constant): This will copy files from server to server.
 --ignore-existing (contsant): This will sometimes ignore the existing files.
-r (constant): means, recursive, it will copy all subfiles and files inside the folder.
/home/admin/domains/s1.ifelse.tv/public_html/ifelse (variable): The folder or file you need to backup.
george@5.199.168.114 (variable): The destination server. As you see, I didn't enter the root account.

/home/george/ifelse (variable): The destination folder on the other server (make sure you create one). 

3. It will ask for the other server's password, enter it:
4. It will begin copying files:

You should leave it for work, as it might take a lot of time. This works pretty well.

Good luck!
Share:

0 comments:

Post a Comment