title: how to keep file ownership while using tar
body: <p>I am currently writing an automatic backup script for our servers. i am using the UNIX tar command in the script to archive the code repositories.</p>
  
  <p>in my PERL script i am using the tar command as follows:</p>
  
  <pre><code>system("tar -jcpf $destPath/$string.tar.bz2 -X $exclusionFile $targetPath");
  </code></pre>
  
  <p>i want to keep file ownerships when extracting the tar archive. i tried to list the tar archive contents with</p>
  
  <pre><code>tar -jtvf
  </code></pre>
  
  <p>and the list contained the correct file ownerships for each file, but when extracting the archive, the file ownership changes to the current user.</p>
  
  <p>is there any way to extract a tar archive and keep the original file ownerships for each file?</p>