Tar a directory but dont store full absolute paths in the archive

Mistake producing Gemini contented Question & Answer :

I person the pursuing bid successful the portion of a backup ammunition book:

tar -cjf site1.bz2 /var/www/site1/ 

Once I database the contents of the archive, I acquire:

tar -tf site1.bz2 var/www/site1/kind.css var/www/site1/scale.html var/www/site1/page2.html var/www/site1/page3.html var/www/site1/photographs/img1.png var/www/site1/pictures/img2.png var/www/site1/subdir/scale.html 

However I would similar to distance the portion /var/www/site1 from listing and record names inside the archive, successful command to simplify extraction and debar ineffective changeless listing construction. Ne\’er cognize, successful lawsuit I would extract backuped web sites successful a spot wherever net information weren’t saved nether /var/www.

For the illustration supra, I would similar to person :

tar -tf site1.bz2 kind.css scale.html page2.html page3.html photographs/img1.png photos/img2.png subdir/scale.html 

Truthful, that once I extract, information are extracted successful the actual listing and I don’t demand to decision extracted records-data afterwards, and truthful that sub-listing constructions is preserved.

Location are already galore questions astir tar and backuping successful stackoverflow and astatine another locations connected the net, however about of them inquire for dropping the full sub-listing construction (flattening), oregon conscionable adhd oregon distance the first / successful the names (I don’t cognize what it modifications precisely once extracting), however nary much.

Last having publication any of the options recovered present and location arsenic fine arsenic the guide, I tried :

tar -cjf site1.bz2 -C . /var/www/site1/ tar -cjf site1.bz2 -C / /var/www/site1/ tar -cjf site1.bz2 -C /var/www/site1/ /var/www/site1/ tar -cjf site1.bz2 --part-parts=three /var/www/site1/ 

However no of them labored the manner I privation. Any bash thing, any others don’t archive sub-directories anymore.

It’s wrong a backup ammunition book launched by a Cron, truthful I don’t cognize fine, which person runs it, what is the way and the actual listing, truthful ever penning implicit way is required for the whole lot, and would like not altering actual listing to debar breaking thing additional successful the book (due to the fact that it doesn’t lone backup web sites, however besides databases, past direct each that to FTP and many others.)

However to accomplish this?

Person I conscionable misunderstood however the action -C plant?

tar -cjf site1.tar.bz2 -C /var/www/site1 . 

Successful the supra illustration, tar volition alteration to listing /var/www/site1 earlier doing its happening due to the fact that the action -C /var/www/site1 was fixed.

From male tar:

Another Choices -C, --listing DIR alteration to listing DIR