How do I create a
- A list of FULL PATH files (such as
- that includes both directories AND files
- that preserves the ownership AND permissions of both files and directories when extracted?
This is how my list of files (
dbfiles.log) looks like:
[oracle@test ~]$ cat dbfiles.log /u01/app/oracle/product/12.2.0/dbhome_1/dbs/initDEVR.ora /u01/app/oracle/product/12.2.0/dbhome_1/dbs/orapwDEVR /u01/app/oracle/product/12.2.0/dbhome_1/dbs/spfileDEVR.ora /u01/app/oracle/oradata/DEVR/control01.ctl /u01/app/oracle/oradata/DEVR/control02.ctl /u01/app/oracle/oradata/DEVR/redo01.log /u01/app/oracle/oradata/DEVR/redo02.log /u01/app/oracle/oradata/DEVR/redo03.log /u01/app/oracle/oradata/DEVR/sysaux01.dbf /u01/app/oracle/oradata/DEVR/system01.dbf /u01/app/oracle/oradata/DEVR/temp01.dbf /u01/app/oracle/oradata/DEVR/undotbs01.dbf /u01/app/oracle/oradata/DEVR/users01.dbf [oracle@test ~]$
This is how I am doing it today:
tar -czvf TARFILENAME.tar.gz -T dbfiles
However it requires manual permission configuration after extracting. By the way, I have to use
sudo to extract the file, so directories get
root:root ownership and not the original
oracle:oinstall as needed.
I found some references suggesting that tar's flag
--no-recursion could solve the problem:
tar -zcf file.tgz --no-recursion abc --recursion abc/def
I believe this is the right approach, but I'm not sure how can I make this work with my file list. Maybe using
find to go through the list and send output to the tarball? I'm honestly not sure.