Tar a directory, but don't store full absolute paths in the archive

前端 未结 9 953
鱼传尺愫
鱼传尺愫 2020-12-04 05:14

I have the following command in the part of a backup shell script:

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

When I list the contents of the archi

9条回答
  •  情话喂你
    2020-12-04 05:23

    Low reputation (too many years of lurking, sigh) so I can't yet comment inline, but I found the answer from @laktak to be the only one that worked as intended on Ubuntu 18.04 -- using tar -cjf site1.tar.bz2 -C /var/www/site1 . on my machine resulted in all the files I wanted being under ./ inside the tar.bz2 file, which is probably ok but there is some risk of inconsistent behavior across OSs when un-tarring.

提交回复
热议问题