I would like to put everything into an archive from a given directory, while also saving the whole dierctory layout, so superior directory names would be required.I run the following command:tar --create --gzip --recursion --file=/home/user/test_backup.tgz --directory=/home/user/opt .However this only saves the directory layout from under opt.dir1dir1/filefile1file2As I understand from the manual, I should use --absolute-names or -P, but neither of them works when I add them to the command above.tar --absolute-names --create --gzip --recursion --file=/home/user/test_backup.tgz --directory=/home/user/opt .What could be the problem?The desired directory layout in the archive should be:/home/user/opt/dir1/home/user/opt/dir1/file/home/user/opt/file1/home/user/opt/file2
Tar --absolute-names flag does not work
backup;tar;directory structure;compression;archive
When you use --directory FOO . you're telling tar to change to the FOO directory and start archiving from there.If you want full path names then you should specify them as the pattern.egtar -czf /home/user/test_backup.tgz /home/user/optHowever this will strip off the leading / character, so you need to tell tar to not do that:tar --absolute-names -czf /home/user/test_backup.tgz /home/user/opt