21. Nov. 2008

When transferring data from one server to another – maybe for backup reason – most people use tar to create an archive. Then they copy it to the new server and untar it or leave it as a tarfile as backup.

Working with UNIX and using a trick  you can transfer it with compression and speed up the whole transfer time a lot.

Using the output result of  a command directly as the command line input of a second command  using a  Unix Pipe the need of writing it down to disk first no longer exists. Finally accessing the remote system though a ssh tunnel will even transfer the compressed data over the network within one single step.

Invoking the following single command will transfer all your data within sourcedirectory an Server B and immediately store it locally  on Server B within a compress archive:

ssh username@hostname “cd /sourcedirectory/ ; tar czf – .” > /targetdirectory/filename.tgz

While the following variation:

ssh username@hostname “cd /sourcedirectory/ ; tar czf – .”> /targetdirectory/filename.tgz| tar xvf –

will directly extract it again for you on the your local system.

No comments yet

No comments yet.

Sorry, the comment form is closed at this time.