[CentOS] Remote archiving with tar over ssh

Les Mikesell lesmikesell at gmail.com
Fri Aug 12 18:13:14 UTC 2005


On Fri, 2005-08-12 at 11:52, James B. Byrne wrote:

> d. I cannot get tar to pipe find'ed files to the remote server over 
> ssh.
> 
> My current command line looks like this.
> 
> find / -name "*.conf" | xargs -t tar -zcvf - | ssh \
> hostname.domain.tld \
> "cat > /var/spool/lvm_backups/hostname.city/confs.$(date 
> +'%Y%m%d').tar.gz"
> 
> I have tried replacing "tar -zcvf -" with "tar -zcvf - {}" and "tar -
> zcvf {}" to no avail.  The problem is that tar does not see the pipe 
> to ssh and exits with signal 13.  What am I missing? 

That looks right, but I'd guess that xargs isn't constructing
quite the command you expect.  It isn't safe for several reasons
(files with newlines or shell metacharacters in the name, for
example, or a big enough expansion that xargs decides it need
to run the command more than once).  I'd probably use cpio
instead of tar for something that needs to be driven by
find, but it would probably also work to use the gnutar option
"-T -" to make it read the file list from stdin.  But think
about what happens if someone names a directory xxx.conf...

-- 
  Les Mikesell
    lesmikesell at gmail.com





More information about the CentOS mailing list