![]() ![]() It's inside a backup shell script launched by a Cron, so I don't know well, which user runs it, what is the path and the current directory, so always writing absolute path is required for everything, and would prefer not changing current directory to avoid breaking something further in the script (because it doesn't only backup websites, but also databases, then send all that to FTP etc. Some do nothing, some others don't archive sub-directories anymore. ![]() Tar -cjf site1.bz2 -strip-components=3 /var/www/site1/īut none of them worked the way I want. I seem to re-call something like this: tar -cvf /tmp/file. Tar -cjf site1.bz2 -C /var/www/site1/ /var/www/site1/ 1 12-07-2010 BeefStu Registered User 137, 14 tar and compress in one step I know there is a way to tar up directory and sub-directories and have it compressed all in one command but but the syntax escapes me. There are already many questions about tar and backuping in stackoverflow and at other places on the web, but most of them ask for dropping the entire sub-directory structure (flattening), or just add or remove the initial / in the names (I don't know what it changes exactly when extracting), but no more.Īfter having read some of the solutions found here and there as well as the manual, I tried : tar -cjf site1.bz2 -C. We can use different compression techniques to get a compressed output. Another command x can preserve directory structures in archives. By default, tar only archives the files without compression but using some portions. So, that when I extract, files are extracted in the current directory and I don't need to move extracted files afterwards, and so that sub-directory structures is preserved. Compress, extract, archive and optimize with the 7z.exe executable. When I list the contents of the archive, I get: tar -tf site1.bz2īut I would like to remove the part /var/For the example above, I would like to have : tar -tf site1.bz2 Directories are archived recursively, unless the -no-recursion option is given. Arguments supply the names of the files to be archived. foo/ something.txt another.txt bar/ something-else.txt Is there a way I can modify the. A few notes: Recursion is the default, from the tar man pages: -c, -create Create a new archive. I have the following command in the part of a backup shell script: tar -cjf site1.bz2 /var/www/site1/ tar archive, and when I extract it, it gives me a single folder foo containing some more stuff, like this. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |