Excluding a file from tar...

The title is not as easy as it sounds.... I am trying to exclude and file while ssh and untaring the file on the fly.

The command I am using is... The command typically works but recently I've add the X option along with the exclude file. Essentially, the exclude file is being ignored when run on the fly, as below.

tar -cvfX - /usr/local/bin/exclude.txt ${var} | ssh ${system} "(cd /zones/${zone}/root; tar xnf -)"

Running the following works all the time....

tar -cvfX new.tar /usr/local/bin/exclude.txt /export/home

But when adding the ssh along with the exclude file, it fails.

Any ideas?

Thanks, :mad::mad:

May help if you put the output of uname -a so folks know what OS this is ...

I tried your command on Solaris 10 - changed it to the following and it worked - of course, ${var} and ${system} were actually set versus getting the value from a variable - change " to ' and give it a try:

tar -cvfX - /tmp/notar.info /var/test | ssh mytestsystem '(cd /zones/${zone}/root; tar xnf -)'

You may find these threads helpful:
http://www.unix.com/unix-dummies-questions-answers/22201-exclude-directory-tar.html
http://www.unix.com/shell-programming-scripting/99616-possible-scp.html

The program is working now. Turns out I was missing a "." in front of the directory to be tar'd.