tags:

views:

242

answers:

1

tar zcvf Test.tar.gz /var/trac/test /var/svn/test

So far I have:

<target name="archive" depends="init">
    <tar compression="gzip" destfile="test.tar.gz">
        <tarfileset dir="/">
            <include name="/var/trac/test" />
        </tarfileset>
        <tarfileset dir="/">
            <include name="/var/trac/svn" />
        </tarfileset>
    </tar>
</target>

With debugging on, it always says "No sources found" so I'm a bit perplexed on what to do next.

+1  A: 

There are several things here that can go wrong:

  1. Are /var/trac/test and /var/svn/test files or directories? Real tar would work fine with both; your task - the way it's written right now - would only work with files but not folders.

  2. Do you (or, rather, does Ant process) have adequate permissions?

  3. <include> elements contain patterns, which are generally relative to base dir. You're specifying them as absolute.

I would rewrite the above as:

<target name="archive" depends="init">
  <tar compression="gzip" destfile="test.tar.gz">
    <tarfileset dir="/var/trac" prefix="/var/trac">
      <include name="test/**" /> 
      <include name="svn/**" />
    </tarfileset>
  </tar>
</target>

prefix allows you to explicitly specify the path with which files in Tar archive should begin.

/** within <include> tells Ant to take all the files from that folder and all its subfolders. If /var/trac/test and /var/svn/test are indeed files and not folders then you can omit that.

ChssPly76
I had some mistakes in my example task, but with a small amount of finagling (two tarfilesets, one for /var/svn/test and one for /var/trac/test), it worked perfectly. Thanks a ton!
Toxygene