I want to create a tar.gz
file of a directory which will be owned by a certain user and group (and not by root
, who is creating the archive).
Basically, I want to combine the following to one single step:
tar -cvz -f temp-backup.tar.gz temp/chown absonegative:absonegative temp-backup.tar.gz
Is that possible in one single pass? I want to avoid that there is a (albeit very small) period in which the file exists as root:root
, as my current backup solution has problems with that (I am trying to fix that as well).
Note that I want to retain the ownership of the files inside the archive, as is already covered if you execute tar
as root
. I only want to alter the ownership of the result.