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.
in my PERL script i am using the tar command as follows:
system("tar -jcpf $destPath/$string.tar.bz2 -X $exclusionFile $targetPath");
i want to keep file ownerships when extracting the tar archive. i tried to list the tar archive contents with
tar -jtvf
and the list contained the correct file ownerships for each file, but when extracting the archive, the file ownership changes to the current user.
is there any way to extract a tar archive and keep the original file ownerships for each file?
Supply the option --same-owner
to tar while extracting.
tar --help
tells:
--same-owner
create extracted files with the same ownership
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With