Skip to main content

Compression Comparison

There is no "best" compression tool for every backup. Your choice is a trade-off between CPU/time (how long it takes to create and restore) and size (how much storage/bandwidth you save). This page gives a practical comparison for WordPress VPS operations.

Quick Summary
  • Default for WordPress files: tar.zst (or tar.gz if you want maximum compatibility).
  • Default for SQL dumps and logs: zstd or gzip.
  • Use xz and high-compression 7z for cold storage (smallest, slowest).
  • Use zip when recipients are on Windows/macOS and you need simple extraction.

Practical recommendations

Backup itemGood defaultNotes
WordPress files (/var/www/...)tar.zstGreat balance of speed and size
WordPress database dump (.sql)zstdFast compression and fast restore
Logs (/var/log/...)gzip or zstdOften managed by logrotate; keep it simple
Cross-platform handoffzipMost portable format
Encrypted archive7z (AES-256)Also supports multi-part archives

Tool comparison (high level)

This table focuses on the most common tools you will see on a VPS.

Tool / formatTypical useCompression ratioCPU/time costSplit supportJoin support
tarDirectory archivingnonelowyes (with split)yes (with cat)
gzip (.gz)Single-file compressionmediumlowno (use split)yes (cat then gunzip)
zstd (.zst)Single-file compressionmedium-highlow-mediumyes (streamable)yes (zstdcat)
xz (.xz)Single-file compressionvery highhighno (use split)yes (cat then xz -d)
tar.gzDirectory backupmediummediumyes (with split)yes
tar.zstDirectory backuphighmediumyes (with split)yes
tar.xzDirectory backupvery highvery highyes (with split)yes
zip (.zip)Cross-platform archivemediummediumyes (zip -s)yes (zip -FF)
7z (.7z)High compression + encryptionhigh-very highhighyes (-v)yes (auto-detect parts)

Split and join (quick reference)

Splitting is useful when you have upload limits, object storage part limits, or you want smaller chunks for transport.

Split a file into 5GiB parts:

split-archive-into-parts.sh
split -b 5G /backups/wp-files-2026-03-01.tar.zst /backups/wp-files-2026-03-01.tar.zst.part-

Join parts back into a single file:

join-split-parts.sh
cat /backups/wp-files-2026-03-01.tar.zst.part-* > /backups/wp-files-2026-03-01.tar.zst

warning

When joining with cat, make sure parts are in the correct order (lexicographic order for the default split suffixes). If you rename parts, sort them carefully before joining.

Notes for WordPress backups

  • For faithful Linux restores (ownership/permissions), prefer tar-based archives.
  • For operational backups, restore speed matters as much as archive size.
  • High compression can hide bottlenecks: CPU-bound compression can be slower than the network.
More detailed view (categories)
CategoryBest choicesWhy
Best balance (fast + small)zstd, tar.zstExcellent speed/ratio
Smallest archivesxz, tar.xz, 7z -mx=9Maximum ratio, slow
Most compatiblegzip, tar.gz, zipSupported almost everywhere
Best for large DB dumpszstd (higher levels if off-peak)Great restore speed

Verification commands

Before you delete source data (or before you trust an offsite copy), run a quick integrity check.

FormatQuick integrity check
.tartar -tf archive.tar >/dev/null
.tar.gztar -tzf archive.tar.gz >/dev/null
.tar.zstzstd --test archive.tar.zst (and tar -I zstd -tf archive.tar.zst >/dev/null)
.tar.xzxz -t archive.tar.xz (and tar -tJf archive.tar.xz >/dev/null)
.gzgzip -t file.gz
.zstzstd --test file.zst
.xzxz -t file.xz
.zipunzip -t file.zip
.7z7z t file.7z

Example checks:

verify-common-archive-formats.sh
tar -tzf /backups/wp-files-2026-03-01.tar.gz >/dev/null
gzip -t /backups/wp-db-2026-03-01.sql.gz
zstd --test /backups/wp-files-2026-03-01.tar.zst
unzip -t /backups/wp-handoff-2026-03-01.zip

Compression levels (rules of thumb)

Higher levels are smaller but cost more CPU. For operational backups, restore speed often matters more than squeezing the last 5-10%.

  • gzip -1 to gzip -6: common defaults; use -1 for speed.
  • zstd -1 to zstd -6: great defaults for daily backups; -10 to -15 for colder data.
  • xz -6 to xz -9: use for cold storage only unless you enjoy waiting.
  • 7z -mx=9: maximum compression, high CPU; best when encryption is also required.

Example: a WordPress backup layout that restores fast

Instead of putting everything into one giant archive, many operators keep two artifacts:

  • wp-files-YYYY-MM-DD.tar.zst
  • wp-db-YYYY-MM-DD.sql.zst

This makes verification and partial restores easier.

example-backup-layout.txt
/backups/
wp-files-2026-03-01.tar.zst
wp-db-2026-03-01.sql.zst

Performance tips

  • Run heavy compression off-peak.
  • Prefer zstd over xz for daily jobs.
  • Consider lowering CPU priority for cron backups:
run-compression-with-lower-priority.sh
nice -n 10 ionice -c2 -n7 tar -I zstd -cvf /backups/wp-files-$(date +%F).tar.zst /var/www/html

Troubleshooting

SymptomLikely causeFix
Archive is small but restore is very slowToo-high compression levelUse zstd at a lower level for daily backups
Restore overwrote unexpected pathsArchive contains absolute pathsUse tar -C /path ... . patterns
Split parts do not join cleanlyParts out of order or missingRe-download and join in correct order
unzip restores with weird permissionsZip portability trade-offUse tar for Linux-native restores
Backup job spikes load and times outCPU/disk bottleneckLower level, add nice/ionice, schedule off-peak
Cheat sheet
TaskCommand
Best default for directoriestar -I zstd -cvf out.tar.zst dir/
Best default for SQL dumps`mysqldump ...
Portability handoffzip -r out.zip dir/
Smallest cold storagetar -cJf out.tar.xz dir/
Split 5G chunkssplit -b 5G file part-
Join chunkscat part-* > file
Mini quiz
  1. Why is tar usually preferred over zip for Linux server restores?

  2. When would you choose xz over zstd?

  3. What is the first command you run before trusting a backup archive?

  4. What can go wrong if you extract an archive with absolute paths?