Compression
Overview
The backup program supports multiple compression formats. By default, it uses Zstandard (tar.zst) compression, which offers the best balance of compression ratio and speed.
Supported Formats
| Format | Extension | Description | Use Case |
|---|---|---|---|
tar.zst | .tar.zst | Default. Zstandard compression via Python 3.14 built-in | Best overall choice: fast and high compression |
tar.gz | .tar.gz | Gzip compression | Wide compatibility, good balance |
tar.bz2 | .tar.bz2 | Bzip2 compression | Higher compression, slower |
tar.xz | .tar.xz | LZMA compression | Highest compression, slowest |
tar | .tar | Uncompressed archive | Fast, no compression overhead |
zip | .zip | ZIP archive with deflate | Cross-platform compatibility |
gzip | .gz | Gzip single file | For single file backups only |
Setting Compression Format
Use the BACKUP_COMPRESSION environment variable:
export BACKUP_COMPRESSION=tar.zst # Default
python main.pyFormat Details
Zstandard (tar.zst) - Recommended
export BACKUP_COMPRESSION=tar.zstAdvantages:
- Excellent compression ratio (similar to bzip2)
- Very fast compression and decompression
- Built into Python 3.14+ (no external dependencies)
- Modern, actively developed
Best for: Most use cases, especially large backups
Gzip (tar.gz)
export BACKUP_COMPRESSION=tar.gzAdvantages:
- Universal compatibility
- Good balance of speed and compression
- Standard on Unix systems
Best for: Maximum compatibility
Bzip2 (tar.bz2)
export BACKUP_COMPRESSION=tar.bz2Advantages:
- Better compression than gzip
- Widely supported
Best for: When file size is more important than speed
LZMA/XZ (tar.xz)
export BACKUP_COMPRESSION=tar.xzAdvantages:
- Highest compression ratio
- Good for long-term archival
Best for: Maximum compression, infrequent access
Uncompressed Tar
export BACKUP_COMPRESSION=tarAdvantages:
- Fast backup and restore
- Preserves directory structure
- No CPU overhead
Best for: Fast local backups, pre-compressed data
ZIP
export BACKUP_COMPRESSION=zipAdvantages:
- Cross-platform (Windows, Mac, Linux)
- Individual file access without full extraction
Best for: Windows compatibility, heterogeneous environments
Gzip Single File
export BACKUP_COMPRESSION=gzipLimitations:
- Only works for single file backups
- Raises error if source is a directory
Best for: Compressing individual large files
Compression Comparison
Based on typical mixed data (documents, code, configs):
| Format | Relative Speed | Relative Size | CPU Usage |
|---|---|---|---|
| tar | ⚡⚡⚡⚡⚡ Fastest | 💾💾💾💾💾 Largest | ▁ Minimal |
| tar.zst | ⚡⚡⚡⚡ Very Fast | 💾💾 Small | ▃ Low |
| tar.gz | ⚡⚡⚡ Fast | 💾💾💾 Medium | ▄ Medium |
| zip | ⚡⚡⚡ Fast | 💾💾💾 Medium | ▄ Medium |
| tar.bz2 | ⚡⚡ Moderate | 💾💾 Small | ▆ High |
| tar.xz | ⚡ Slow | 💾 Smallest | ▇ Very High |
Recommendations
For Daily Backups
export BACKUP_COMPRESSION=tar.zstFast, efficient, modern default.
For Long-Term Archives
export BACKUP_COMPRESSION=tar.xzMaximum compression for storage savings.
For Maximum Compatibility
export BACKUP_COMPRESSION=zipWorks everywhere, easy to extract.
For Fast Local Backups
export BACKUP_COMPRESSION=tarNo compression overhead, preserves directory structure.
Custom Archive Names
You can specify a custom archive name:
export BACKUP_ARCHIVE_NAME=myproject_backup
export BACKUP_COMPRESSION=tar.zstThis creates: myproject_backup.tar.zst
If not specified, the default format is:
backup_{source_dirname}_{timestamp}.{extension}Example: backup_documents_20250109_143022.tar.zst