Copying files using SSH.

Marc Wagner, January 30, 2023

As an Inter­net agen­cy, we also hand­le relo­ca­ti­ons and migra­ti­ons of web­sites, por­tals and appli­ca­ti­ons. In some cases, this can alre­a­dy mean seve­ral GB of data.

The most effec­ti­ve way to copy data from one sys­tem to ano­ther is via SSH. Of cour­se, the pre­re­qui­si­te for this is that both hos­ting packa­ges offer SSH access.

One way to copy files bet­ween two ser­vers is with SCP.

To copy the data from your local server to a remote server #

Log in via SSH to the ser­ver from which you want to copy the data.

Then enter the fol­lo­wing line in the con­so­le:

scp -r /pfad/zum/lokalen/verzeichnis [email protected]:/pfad/zum/remote/verzeichnis

After ente­ring your pass­word, the copy­ing pro­cess should alre­a­dy start.

To copy the data from a remote server to your local server #

Log in via SSH to the ser­ver whe­re you want to insert the data.

Then enter the fol­lo­wing line in the con­so­le:

scp -r [email protected]:/pfad/zum/remote/verzeichnis /pfad/zum/lokalen/verzeichnis

After ente­ring your pass­word, the copy­ing pro­cess will begin.

Run SCP in the background #

If you don’t want to watch the pro­cess per­ma­nent­ly, you can move it to the back­ground.

Press CTRL+Z to pau­se copy­ing. After­wards you can use bg to restart the pro­cess in the back­ground wit­hout having to stay the­re. With exit you can clo­se the ter­mi­nal.

  1. CTRL+Z to pau­se the pro­cess
  2. bg in the ter­mi­nal to run the pro­cess in the back­ground.
  3. exit to clo­se the ter­mi­nal.

If SCP is not the right thing for you, you can look at copy­ing files using rsync as an alter­na­ti­ve.

Was this artic­le hel­pful? How do you copy the data when you make a move? Wri­te us a com­ment. We app­re­cia­te your feed­back.

Avatar of Marc Wagner
Marc Wagner

Hi Marc here. I'm the founder of Forge12 Interactive and have been passionate about building websites, online stores, applications and SaaS solutions for businesses for over 20 years. Before founding the company, I already worked in publicly listed companies and acquired all kinds of knowledge. Now I want to pass this knowledge on to my customers.

Similar Topics

Comments

Leave A Comment