🗄️ How to Create a tar+bzip2 Website Archive While Ignoring VCS Folders (.git and others)
When backing up web projects, you often need to create a compact archive without including version‑control system directories such as .git, .svn, .hg, or .bzr.
These folders can take up hundreds of megabytes and are completely unnecessary in a production backup.
On Linux, this is very easy — you just need to use
tar
with the
–exclude-vcs
option.
🔍 Why You Should Exclude VCS Directories
Folders like
.git/
contain:
- full commit history
- temporary files
- caches
- internal indexes
As a result:
- your archive becomes 5–20× larger than needed
- you waste storage space
- backup creation and transfer take longer
For production backups, it’s best to leave them out.
🧰 The
–exclude-vcs
Option in tar
GNU Tar provides a special option:
--exclude-vcs
It automatically excludes all standard version‑control directories:
- .git
- .svn
- .hg
- .bzr
- _darcs
- CVS
This is the most convenient way to create a clean archive.
🧩 Example: Creating a tar.bz2 Website Archive Without VCS Folders
Let’s say your website is located at:
/home/taras/websites/shkodenko.com/
You want to create an archive in your home directory under
_backups
, with a timestamp in the filename.
✔️ Ready‑to‑use command:
cd /home/taras/websites/shkodenko.com/ tar --exclude-vcs -cpjf ~/_backups/_shkodenko.com__no_vcs__$(date +'%Y-%m-%d_%H-%M').tar.bz2 ./
What this command does:
-
cd ...
— moves into the website root
-
tar
— runs the archiver
-
--exclude-vcs
— excludes all VCS directories
-
-c
— create an archive
-
-p
— preserve file permissions
-
-j
— use bzip2 compression (better than gzip)
-
-f
— specify the output filename
-
$(date +'%Y-%m-%d_%H-%M')
— adds date and time to the filename
-
./
— archives the current directory
The resulting file will look like:
_shkodenko.com__no_vcs__2026-05-03_15-20.tar.bz2
📦 Why bzip2?
tar.bz2
archives usually:
- compress better than gzip (
.tar.gz
)
- work slower, but produce smaller files
For website backups, this is often the ideal choice.
🧪 Verifying the Archive
List archive contents:
tar -tjf archive.tar.bz2
Extract the archive:
tar -xpjf archive.tar.bz2
📝 Conclusion
Creating a clean website backup without
.git
and other VCS directories is simple.
Just use
tar
with the
--exclude-vcs
option, and you’ll get a neat, compact, and production‑ready archive.