2

How can I create a .tar archive of a file (say /root/bugzilla) on a remote machine and store it on a local machine. SSH-KEYGEN is installed, so I can by pass authentication.

I am looking for something along the lines of:

tar -zcvf Localmachine_bugzilla.tar.gz /root/bugzilla
itsjeyd
  • 5,070
  • 2
  • 30
  • 49
Rajeev
  • 44,985
  • 76
  • 186
  • 285
  • possible duplicate of [Remote Linux server to remote linux server dir copy. How?](http://stackoverflow.com/questions/69411/remote-linux-server-to-remote-linux-server-dir-copy-how) – Peter G. Mar 30 '11 at 08:17

2 Answers2

9
ssh <host> tar -zcvf - /root/bugzilla > bugzilla.tar.gz

avoids an intermediary copy.

See also this post for a couple of variants: Remote Linux server to remote linux server dir copy. How?

Community
  • 1
  • 1
Peter G.
  • 14,786
  • 7
  • 57
  • 75
0

Something like:

ssh <host> tar -zcvf bugzilla.tar.gz /root/bugzilla
scp <host>:bugzilla.tar.gz Localmachine_bugzilla.tar.gz

Or, if you are compressing it just for the sake of transfer, scp compression option can be useful:

scp -R -C <host>:/root/bugzilla .

This is going to copy the whole /root/bugzilla directory using compression on the wire.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271