Recently, I ran into a Situation where I had to copy 10 GB of Data from one web server to another. If this was many years ago, I would first download it to my computer and then upload it to the new server. But things have changed a lot and we have SSH now.
SCP is a very popular command to transfer files from one server to another. And today I copied 10 GB of data via SSH without keeping my laptop on or the SSH Connection open. My reason was that the process was going to take too long, and i do not have faith in my internet connection.
The key principle behind running an SCP process in the background is disowning the process. You can do it in just a few lines of codes.
//After you have Logged in, begin the SCP Process
scp my-dir/source.zip email@example.com:/var/www/
//Press Control + Z
CTRL + Z
//Execute the bg command for background process
//Disown the process with this command
That’s it and the process will continue running in the background. You can close your laptop and go out for a lunch(or dinner if it’s too late).
How To Verify that the SCP Command is running?
90% chances are you are transferring a zip file or something. Log in to your Remote server and keep checking the size of the file at remote destination You will notice it keeps changing, ensuring that the scp is running even after you have logged out.