Secure way to transfer files between servers

For most of the common Linux/Unix systems, they have good concepts of pipeline, which give us a chance to copy data easliy among different servers.

What you need to do is to establish a instant connection between your servers, and we offen create such connections by OpenSSH. If you’re running openssh, the connection is encryped. When established, tranferring files between servers are much like a local copy or move. What’s more, It’s much secure as you are using a encryped channel.

I’ll give you some quick examples, it would be helpful for your daily system administration. if you want to build a reuse SSH connection, please google around 😉 :

Copy large amount of small files quickly (without compress)
tar cf – * –exclude=logs/* | ssh -p PORT user@remote.admon.org “cd /node1/; tar xvf -“

Copy large amount of small files quickly (with compress)
tar zcf – * –exclude=logs/* | ssh -p PORT user@remote.admon.org “cd /node1/; tar zxvf -“

Dump Postgres Database using pg_dump
pg_dump -U USER DATABASE-NAME | ssh -p PORT user@remote.admon.org “dd of=/backup/pgsql-$(date +’%d-%m-%y’)”

Dump MySQL Database using mysqldump
mysqldump -u USER -p’PASSWORD’ DATABASE-NAME | ssh -p PORT user@remote.admon.org “dd of=/backup/mysql-$(date +’%d-%m-%y’)”

Share Button

One thought on “Secure way to transfer files between servers

Leave a comment

Your email address will not be published. Required fields are marked *