I am trying to create a one line command that will: 1. Find all files ending in .conf 2. tar these over ssh to a remote server. I have reached this point in my trials. a. I can find the files. b. I can tar them locally. c. I can get a simple fileset tar'ed to a remote server over ssh using tar -zvcf - /some/fileset | ssh host.domain.tld "cat > /backup/tarfile.tar.gz 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? Regards, Jim -- *** e-mail is NOT a secure channel *** James B. Byrne mailto:ByrneJB.<token>@Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3CE delivery <token> = hal
Any particular reason you're not using something like rsync -av -e ssh or similar (or if not sure on rsync, might be an avenue worth looking at, I use it all the time)? On 8/12/05, James B. Byrne <ByrneJB at harte-lyne.ca> wrote:> I am trying to create a one line command that will: > > 1. Find all files ending in .conf > 2. tar these over ssh to a remote server. > > I have reached this point in my trials. > > a. I can find the files. > > b. I can tar them locally. > > c. I can get a simple fileset tar'ed to a remote server over ssh > using tar -zvcf - /some/fileset | ssh host.domain.tld "cat > > /backup/tarfile.tar.gz > > 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? > > Regards, > Jim > > -- > > *** e-mail is NOT a secure channel *** > James B. Byrne mailto:ByrneJB.<token>@Harte-Lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3CE delivery <token> = hal > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >
On 8/12/05 9:52 AM, James B. Byrne wrote:> I am trying to create a one line command that will: > > 1. Find all files ending in .conf > 2. tar these over ssh to a remote server.How about tar c $(find / -name \*.conf) | ssh host.com "gzip -c > file.tar.gz" -- Paul Heinlein <> heinlein at madboa.com <> www.madboa.com
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
Ok. I discovered how to make exclusions work via find: find / \( -name "*.conf" -a -not -name "ld.so.conf" \) -type f - print That should also fix any problems with directories ending in .conf. -- *** e-mail is NOT a secure channel *** James B. Byrne mailto:ByrneJB.<token>@Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3CE delivery <token> = hal