zstd - Fast Compression
zstd (Zstandard) is a modern compressor with an unusually good speed-to-ratio trade-off. For WordPress VPS operations, it is a strong default for database dumps and for directory backups when paired with tar (.tar.zst).
- Compress:
zstd file.sql->file.sql.zst - Decompress:
zstd -d file.sql.zstorunzstd file.sql.zst - Test:
zstd --test file.sql.zst - Directory backup:
tar -I zstd -cvf wp-files.tar.zst /var/www/html
When to use zstd
Use zstd when:
- You want fast backups and fast restores.
- You compress large SQL dumps, log bundles, and WordPress file archives.
- You want a good default compression algorithm for automation.
If you need maximum compression for cold storage, consider xz (and accept the time cost).
Prerequisites
-
Ubuntu 22 / 24 LTS VPS.
-
Installed
zstdandtarutilities. -
Basic file permission & path knowledge.
-
Access to WordPress directories such as:
/home/dev_wpstrategist/public_html/,/home/wpbackup/,/var/log/.
Core syntax
# ──────────────────────────────
# 1. Compress a single file (same location)
zstd [OPTION] [INPUT_FILE]
# Example:
zstd /home/dev_wpstrategist/error.log
# → Output: /home/dev_wpstrategist/error.log.zst
# ──────────────────────────────
# 2. Decompress a .zst file
unzstd [INPUT_FILE.zst]
# or
zstd -d [INPUT_FILE.zst]
# Example:
zstd -d /home/dev_wpstrategist/error.log.zst
# → Output: /home/dev_wpstrategist/error.log
# ──────────────────────────────
# 3. Compress with specific level (1–19)
zstd -# [INPUT_FILE]
# Example (max compression):
zstd -19 /home/wpbackup/db.sql
# → Output: db.sql.zst (highest ratio, slower)
# ──────────────────────────────
# 4. Compress and save to another directory
zstd -o [OUTPUT_PATH] [INPUT_FILE]
# Example:
zstd -o /home/wpbackup/db_$(date +%F).sql.zst /home/dev_wpstrategist/db.sql
# ──────────────────────────────
# 5. View compression statistics
zstd -v [INPUT_FILE]
# ──────────────────────────────
# 6. Combine with tar to create a .tar.zst archive (Export)
tar -I zstd -cvf [OUTPUT].tar.zst [SOURCE_DIR]
# Example:
tar -I zstd -cvf /home/wpbackup/wpfiles_$(date +%F).tar.zst /home/dev_wpstrategist/public_html
# ──────────────────────────────
# 7. Extract a .tar.zst archive (Import)
tar -I zstd -xvf [INPUT].tar.zst -C [TARGET_DIR]
# Example:
tar -I zstd -xvf /home/wpbackup/wpfiles_2025-10-25.tar.zst -C /home/dev_wpstrategist/public_html/
# ──────────────────────────────
# 8. Stream backup over SSH
tar -I zstd -cvf - [SOURCE_DIR] | ssh root@remote "cat > /backup/wp_$(date +%F).tar.zst"
# ──────────────────────────────
# 9. Dump & compress WordPress DB
mysqldump -u [USER] -p'[PASS]' [DB_NAME] | zstd -19 -o /home/wpbackup/db_$(date +%F).sql.zst
# ──────────────────────────────
# 10. Decompress & import DB
zstd -dc [INPUT].sql.zst | mysql -u [USER] -p'[PASS]' [DB_NAME]
Key options
| Option | Description | Example | Use Case | CPU Impact |
|---|---|---|---|---|
-# | Compression level 1–19 | zstd -9 file.sql | Adjust ratio vs speed | 🟢 Low–🟡 Medium |
-d | Decompress file | zstd -d file.zst | Restore backups | 🟢 |
-o | Output file path | zstd -o /dest/out.zst file | Store elsewhere | 🟢 |
-v | Verbose | zstd -v file | Show stats | 🟢 |
--rm | Remove source file after compress | zstd --rm file | Save disk space | 🟡 |
--test | Verify archive integrity | zstd --test file.zst | Validate before restore | 🟢 |
--long | Enable large window (better ratio on large files) | zstd --long=27 file | Huge site archives | 🔴 |
tar -I zstd | Integrate with tar | tar -I zstd -cvf backup.tar.zst dir/ | Full WordPress backups | 🟡–🔴 (depends level) |
Examples
Basic Compression
zstd wp-config.php
Output:
wp-config.php.zst : 77.81% compressed (5 KB → 3.9 KB)
Use Case: Light config backup.
CPU Impact: Low.
Max Compression Level
zstd -19 wpdb.sql
Output:
wpdb.sql : 90.2% compressed (120 MB → 11.7 MB)
Use Case: Database archive before transfer.
CPU Impact: High (slower ≈ 3× CPU load).
Keep Original and Save Elsewhere
zstd -o /home/wpbackup/db_2025-10-25.sql.zst /home/dev_wpstrategist/db.sql
Output:
/home/wpbackup/db_2025-10-25.sql.zst : 82.1% ratio
Use Case: Store compressed DB in backup folder.
CPU Impact: Moderate.
Decompress Database
zstd -d /home/wpbackup/db_2025-10-25.sql.zst
Output:
db_2025-10-25.sql restored OK
Use Case: Prepare restore.
CPU Impact: .
Full WordPress Backup as .tar.zst
tar -I zstd -cvf /home/wpbackup/wp_2025-10-25.tar.zst /home/dev_wpstrategist/public_html
Output (snippet):
public_html/wp-admin/
public_html/wp-content/
public_html/wp-includes/
Archive size : 450 MB → 95 MB (78.8% ratio)
Use Case: High-speed compressed site backup.
CPU Impact: – (depends level).
Extract .tar.zst Archive
tar -I zstd -xvf /home/wpbackup/wp_2025-10-25.tar.zst -C /home/dev_wpstrategist/public_html
Output:
Files extracted successfully.
Use Case: Restore entire WordPress directory.
Verify Integrity
zstd --test /home/wpbackup/db_2025-10-25.sql.zst && echo "OK"
Output:
OK
Use Case: Verify backup not corrupted.
CPU Impact: .
Check Compression Stats
zstd -v /home/wpbackup/db_2025-10-25.sql.zst
Output:
Compressed : 110 MB → 9.8 MB (91.1%)
Compression speed : 280 MB/s Decompression speed : 900 MB/s
WordPress VPS use cases
| Use Case | Description | Example Command | Benefit |
|---|---|---|---|
| DB Backups | Compress SQL dumps | `mysqldump … | zstd -19 -o …` |
| Site Files | Full .tar.zst backup | tar -I zstd -cvf backup.tar.zst /var/www/html | Faster transfer |
| Logs | Rotate & compress logs | zstd --rm /var/log/*.log | Save disk space |
| Remote Transfer | Pipe via SSH | `tar -I zstd -cvf - dir | ssh …` |
| Automation | Add to cron | 0 2 * * * tar -I zstd … | Daily backups |
Best practices
- Use
19only for final, non-urgent archives. - For daily backups, prefer
9(balance speed vs ratio). - Always run
-testbefore restoring. - Combine
tar -I zstdto package entire directories. - Automate cleanup of old archives with
find … -delete. - Monitor CPU usage on VPS to avoid overload.
Quick lab
-
Export DB
quick-lab-dump-db.shmysqldump -u root -p wpdb > wpdb.sql -
Compress with zstd
quick-lab-compress-db.shzstd -9 wpdb.sql -
Verify
quick-lab-verify-db.shzstd --test wpdb.sql.zst && echo "Backup Valid" -
Restore
quick-lab-restore-db.shzstd -dc wpdb.sql.zst | mysql -u root -p wpdb
Cheat sheet
zstd file # Compress file → file.zst
zstd -d file.zst # Decompress
zstd -# file # Level (1–19)
zstd -o out.zst in # Custom output
zstd --test file.zst # Verify integrity
tar -I zstd -cvf a.tar.zst dir/ # Create archive
tar -I zstd -xvf a.tar.zst -C /target # Extract archive
zstd -v file # Show stats
zstd --rm file # Compress & remove source
Mini quiz
- What command integrates
zstdwithtar? - Which option verifies a
.zstfile’s integrity? - What is the maximum compression level available?
- How would you decompress
wp_2025-10-25.tar.zstto/var/www/html/? - Which level should you use for daily scheduled backups to balance CPU and speed?
Restore checklist
Use this checklist before restoring a .tar.zst or .sql.zst backup:
- Verify integrity (
zstd --test ...). - Extract to staging (
/tmp/restore-test/). - Confirm expected content exists (
wp-content/uploads/,wp-config.php).
sudo rm -rf /tmp/restore-test
sudo mkdir -p /tmp/restore-test
tar -I zstd -xvf /home/wpbackup/wp_2025-10-25.tar.zst -C /tmp/restore-test
Automation notes
- Avoid very high levels in cron if the VPS is small; start with
-3to-9. - Consider lowering CPU and I/O priority for scheduled backups.
nice -n 10 ionice -c2 -n7 zstd -9 -o /home/wpbackup/db.sql.zst /home/wpbackup/db.sql
Compression is only half the story. A backup you cannot restore quickly is not an operational backup.