Home » Questions » Computers [ Ask a new question ]

Tar: How to ignore the archive itself

Tar: How to ignore the archive itself

I was planning to do a quick backup of my website. So I tried to run the following command in my webroot:

Asked by: Guest | Views: 304
Total answers/comments: 2
Guest [Entry]

"Try

tar cvfz backup.tar.gz *

This way shell extends the *, vs the tar reading current directory. The difference is that the produced archive does not contain root folder.

If you also need to include hidden files (.files) you can try

tar cvfz backup.tar.gz * .??*

This includes .files and prevents inclusion of parent directories."
Guest [Entry]

"I'm sure there's a nicer way, but I always just do it from the a different directory.

tar cvfz backup.tar.gz /path/to/www

This link looks like it has the information you might want."