The day is finally here! SUSE Linux Enterprise 11 is now officially launched today!
Main page at Novell.com -> http://www.novell.com/linux
The opinions on this blog are my own and are not representative of my employers, past or present.
Tuesday, March 24, 2009
Thursday, March 19, 2009
TARing across the network with SSH
I'm getting old and I really thought I did blog about this... until I announced that its there on my blog at my workshop only to find that its NOT.
Anyway, the scenario is you want to tar up some files (or directories) but you want the resulting tar file on a remote machine connected via the network. This saves you some hard disk space locally and you get to do it in one step as opposed to tarring things locally and then copying it over the network.
The prerequisite is the target server has Secure Shell Daemon (SSH) running.
Here it is (and some variants):
tar -zcvf - ./<directory> | ssh <user>@<remoteIP-or-Hostname> 'dd of=<filename>.tar.gz'
Explanation: TAR and GZIP the entire <directory> but send the bits over stream via SSH to remote machine, as <user>, and write the bits into the file <filename>.tar.gz.
tar -cvf - ./<directory> | ssh <user>@<remoteIP-or-Hostname> 'gzip > <filename>.tar.gz'
Explanation: TAR the entire <directory> but send the bits over stream via SSH to remote machine, as <user>, and GZIP the stream into the file <filename>.tar.gz. Similar to first but divides the work of TAR and GZIP across 2 machines... workload management, woo-hoo!
tar -cf - ./<directory> | ssh <user>@<remoteIP-or-Hostname> 'tar -xf -'
Explanation: TAR the entire <directory> but send the bits over stream via SSH to remote machine, as <user>, and UN-TAR the stream into the same directory and file structure of the source machine.
Anyway, the scenario is you want to tar up some files (or directories) but you want the resulting tar file on a remote machine connected via the network. This saves you some hard disk space locally and you get to do it in one step as opposed to tarring things locally and then copying it over the network.
The prerequisite is the target server has Secure Shell Daemon (SSH) running.
Here it is (and some variants):
tar -zcvf - ./<directory> | ssh <user>@<remoteIP-or-Hostname> 'dd of=<filename>.tar.gz'
Explanation: TAR and GZIP the entire <directory> but send the bits over stream via SSH to remote machine, as <user>, and write the bits into the file <filename>.tar.gz.
tar -cvf - ./<directory> | ssh <user>@<remoteIP-or-Hostname> 'gzip > <filename>.tar.gz'
Explanation: TAR the entire <directory> but send the bits over stream via SSH to remote machine, as <user>, and GZIP the stream into the file <filename>.tar.gz. Similar to first but divides the work of TAR and GZIP across 2 machines... workload management, woo-hoo!
tar -cf - ./<directory> | ssh <user>@<remoteIP-or-Hostname> 'tar -xf -'
Explanation: TAR the entire <directory> but send the bits over stream via SSH to remote machine, as <user>, and UN-TAR the stream into the same directory and file structure of the source machine.
Subscribe to:
Posts (Atom)