Have you had situations where disk-space is sparse, so making full tars (although compressed) is impossible? Here is an ssh trick that could help you copy over files without using too much diskspace.
This trick will tar a directory from a computer, but the file that it would normally create, is standard out, so it is redirected back to the script on the computer you are working on. The computer you are working on extracts the information directly, so there is no location where (redundant) files are stored.
ssh user@machine-where-precious-data-is "tar czpf - /some/important/data" | tar xzpf - -C /new/root/directoryYou are now directly copying data from the "machine-where-precious-data-is" to the machine you are working on, using the benefits of tar (preserving permissions, links, etc) but not being hindered by the difficulties of tar. (making these possibly large files and so on.)
I used this trick to copy users directories from one machine to the other.
An alternative command, reverse and not crossing filesystem boundries:
tar cXpf - /some/important/data | ssh user@destination-machine "tar xpf - -C /some/directory/" | About | Consultancy | Articles | Contact |
|
|
|
|
|
| References | Red Hat Certified Architect | By Robert de Bock | Robert de Bock |
| Curriculum Vitae | By Fred Clausen | +31 6 14 39 58 72 | |
| By Nelson Manning | robert@meinit.nl |
Comments
Perfect: ssh
Perfect:
ssh user@machine-where-precious-data-is "tar czpf - /some/important/data" | tar xzpf - -C /new/root/directory
Thanks for a wicked useful trick!
Wow, was looking exactly for
Wow, was looking exactly for that and this page is the first google result for
"generating and copying tar files via ssh"
Greets Patrick
Love this trick. I'd used it
Love this trick. I'd used it many years ago and found myself in the very predicament that you mentioned today. A Google search found your post. Ironically, I am setting up a Drupal site to provide Open Source services because I am fed up with how complex today's "solutions" are in nearly every business.
Anyway, many thanks. Explained very well.
Cheers,
Tony
A really useful tip in
A really useful tip in real-world production environments.