Answer the question
In order to leave comments, you need to log in
How to tar an archive with a given folder structure?
I have a number of folders:
/var/ftp/pub/bkp1
/home/user/bkp2
/home/user/bkp3 I
archive them like this:
tar -cvf bkp_re2.3.tar /var/ftp/pub/bkp1 /home/user/bkp2 /home/user/bkp3
and the folder structure is preserved in the archive the same as it was before archiving.
And I need the following structure in the archive:
/bkp1
/bkp2
/bkp3
How can I do this?
Answer the question
In order to leave comments, you need to log in
We create an archive from the first directory group, and then add another directory group to the existing tar archive:
tar cvfC /path/to/backup/bkp_re2.3.tar /var/ftp/pub/ .
tar vfCr /path/to/backup/bkp_re2.3.tar /home/user .
The -C option can change the current directory during archiving:
tar -cf bkp_re2.3.tar -C /var/ftp/pub/ bkp1 -C /home/user/ bkp2 bkp3
I'm not sure if it will work, but you can try this:
tar -cvf bkp_re2.3.tar -C `pwd` /var/ftp/pub/bkp1 /home/user/bkp2 /home/user/bkp3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question