Mailing List Archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] The Mother of All (bash) Commands

On Monday 17 March 2008 12:46, Godwin Stewart wrote:
>On Tue, 18 Mar 2008 01:51:39 +0900, "Greg Thomson " <> 
>> Here is a cool little bash one liner with explaination.
>Been using just that to back up MySQL data and websites off remote
> servers for yonks.

I've been using something similar for some time as well.

Closely related is a fast and easy way to copy directory trees while 
preserving permissions:
    (cd /src ; tar -cf - .) | (cd /dst ; tar -xvpf -)
Of course, the "." argument to tar may be modified as necessary...

That even works though an ssh pipe:
    (cd /src ; tar -cf - .) | ssh '(cd /dst ; tar -xvpf -)'

Or the other way:
    ssh '(cd /src ; tar -cf - .)' | (cd /dst ; tar -xvpf -)

Depending on the situation, rsync might be better. For a 1-time copy 
running tar through a pipe is usually faster, though. I've used it to 
migrate data.

I suppose it would even be possible to copy between 2 remote machines, 
with all the data piped through the local machine. In most situations 
that would not be an efficient use of bandwidth or CPU time, but i'd 
imagine it has been done before. Perhaps with the local machine being a 
firewall or router or something that can see both of the other hosts 
when they can't see each other. I've never done it before, but this 
*should* work:
    ssh '(cd /src ; tar -cf - .)' | \
    ssh '(cd /dst ; tar -xvpf -)'

Dan Ramaley                            Dial Center 118, Drake University
Network Programmer/Analyst             2407 Carpenter Ave
+1 515 271-4540                        Des Moines IA 50311 USA

Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links