ChaCha20-Authenticated Backup Protection for Directories and Docker Volumes
with authenticated encryption, compression, smart retention, incremental backups, deduplication, and real-time notifications.
Chantik β A robust backup solution originally created for the digital-independence project, now available for general use. Chantik provides protection with ChaCha20-Poly1305 authenticated encryption, smart retention policies, and comprehensive automation features.
| Feature | Description |
|---|---|
| π Encryption | ChaCha20-Poly1305 (primary) with AES-256-CBC fallback |
| π Key Derivation | PBKDF2 with configurable iterations (default: 600,000) |
| π Deduplication | Fixed nonce support for deterministic encryption |
| ποΈ Compression | Gzip with configurable levels (1-9) |
| π³ Docker Support | Backup Docker volumes seamlessly |
| π Incremental Backups | Save storage and speed up backups |
| π Smart Retention | Daily, weekly, and monthly retention policies |
| π Notifications | Real-time alerts via ntfy.sh |
| β Verification | SHA256 checksum verification |
| π Security | Configurable permissions and locking |
| π Logging | Detailed logs for auditing |
Ensure your system has:
- Bash 4.0+
- Docker (if backing up Docker volumes)
- OpenSSL 1.1.1+ (with ChaCha20 support)
- gzip
- tar
- curl
- find
- grep
- sed
- awk
- df
- du
- hostname
- sha256sumInstall missing packages:
# Ubuntu/Debian
sudo apt update
sudo apt install -y openssl gzip tar curl coreutils
# RHEL/CentOS/Fedora
sudo yum install -y openssl gzip tar curl coreutils
# Alpine Linux
apk add openssl gzip tar curl coreutils
# macOS (using Homebrew)
brew install openssl gzip tar curl coreutils-
Clone repository:
git clone https://github.com/ricalnet/chantik.git cd chantik -
Generate encryption key:
openssl rand -base64 32 > encryption.key chmod 600 encryption.key -
(Optional) Generate fixed salt for deduplication:
openssl rand -hex 8 > fixed_salt.txt chmod 600 fixed_salt.txt -
Create configuration from example:
cp chantik.conf.example chantik.conf
-
Edit configuration with your settings:
nano chantik.conf
-
Make script executable:
chmod +x chantik.sh
-
Test the encryption system:
./chantik.sh --test
# Perform backup
sudo ./chantik.sh
# Watch the output:
ββββββββββββββββββββββββββββββββββββββββββββββ
[2026-08-08 10:00:00] ποΈ Starting Chantik (v0.1.1)
[2026-08-08 10:00:00] π¬ ChaCha20-Authenticated Backup Protection
[2026-08-08 10:00:00] π In ChaCha We Trust β Authentically Secured
[2026-08-08 10:00:00]
β
Configuration loaded successfully from: /path/to/chantik.conf
[2026-08-08 10:00:00] π Source: /home/user/digital-independence
[2026-08-08 10:00:00] π Size: 156.2 MB (1,234 files)
[2026-08-08 10:00:00] π³ Volumes: 3 volumes
[2026-08-08 10:00:00] πΎ Target: /media/backup
[2026-08-08 10:00:00] πΏ Free space: 450.5 GB
[2026-08-08 10:00:00] π Encryption: CHACHA20 (Chantik Mode β ChaCha Autentik)
[2026-08-08 10:00:00] π PBKDF2 iterations: 600000
[2026-08-08 10:00:00] π Deduplication: ENABLED (fixed nonce)
[2026-08-08 10:00:00] ποΈ Compression: gzip level 6
[2026-08-08 10:00:00] π Retention: Daily=7, Weekly=4, Monthly=6
[2026-08-08 10:00:00] π Incremental: ENABLED (full backup every 7 days)
[2026-08-08 10:00:00] π Backup directory created: /media/backup/chantik-backup_20260808_100000
[2026-08-08 10:00:01] π¦ Performing FULL backup of /home/user/digital-independence (scheduled full backup)
[2026-08-08 10:00:30] ποΈ Compressing with gzip level 6...
[2026-08-08 10:00:45] β
FULL encrypted backup created: digital-independence_20260808_100000_full.tar.gz.enc (28.3 MB)
[2026-08-08 10:00:45] π¦ Performing FULL backup of Docker volume: postgres_data (scheduled full backup)
[2026-08-08 10:01:15] β
FULL encrypted volume backup created: volume_postgres_data_20260808_100000_full.tar.gz.enc (85.6 MB)
[2026-08-08 10:01:15] π¦ Performing INCREMENTAL backup of Docker volume: redis_cache (since 2026-08-07 10:00:00)
[2026-08-08 10:01:30] π Changed files in volume: 15
[2026-08-08 10:01:30] β
INCREMENTAL encrypted volume backup created: volume_redis_cache_20260808_100000_inc.tar.gz.enc (3.2 MB)
[2026-08-08 10:01:30] β
All backups verified.
[2026-08-08 10:01:30] Rotating backups in /media/backup
[2026-08-08 10:01:31] β
Rotation completed
[2026-08-08 10:01:31] π Running deduplication on /media/backup using hardlink...
[2026-08-08 10:01:35] β
Deduplication complete: 456 .enc files processed (4s)
[2026-08-08 10:01:35] ββββββββββββββββββββββββββββββββββββββββββββββ
[2026-08-08 10:01:35] β
Backup completed successfully
[2026-08-08 10:01:35] ποΈ Chantik β ChaCha20-Authenticated Backup Protection
[2026-08-08 10:01:35] β±οΈ Duration: 1m 35s
[2026-08-08 10:01:35] π¦ Archives: 12 encrypted files (3 full, 9 incremental)
[2026-08-08 10:01:35] πΎ Total size: 117.1 MB
[2026-08-08 10:01:35] π Location: /media/backup/chantik-backup_20260808_100000
[2026-08-08 10:01:35] π Log: /path/to/chantik.log
[2026-08-08 10:01:35] π In ChaCha We Trust β Authentically Secured
[2026-08-08 10:01:35] ββββββββββββββββββββββββββββββββββββββββββββββ
[2026-08-08 10:01:35] ποΈ Chantik β From ChaCha Comes Peace of Mind| Variable | Description | Example |
|---|---|---|
BACKUP_BASE_DIR |
Where encrypted backups are stored | /media/backup |
SOURCE_DIR |
Main directory to backup | /home/user/digital-independence |
DOCKER_VOLUMES |
Array of Docker volume names | ("postgres_data" "redis_cache") |
ENCRYPTION_KEY_FILE |
Path to encryption key | /home/user/chantik/encryption.key |
NTFY_TOPIC |
ntfy.sh topic for notifications | my-backup-topic |
NTFY_TOKEN |
ntfy.sh authentication token | tk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| Variable | Description | Default |
|---|---|---|
ENCRYPTION_CIPHER |
Cipher to use (chacha20 or aes-256-cbc) | chacha20 (auto-detected) |
PBKDF2_ITERATIONS |
Key derivation iterations (100,000+) | 600000 |
FIXED_SALT_FILE |
Fixed salt for deterministic encryption | (optional) |
INCREMENTAL_ENABLED |
Enable incremental backups | true |
FULL_BACKUP_INTERVAL |
Days between full backups | 7 |
RETENTION_DAILY |
Number of daily backups to keep | 7 |
RETENTION_WEEKLY |
Number of weekly backups to keep | 4 |
RETENTION_MONTHLY |
Number of monthly backups to keep | 6 |
GZIP_LEVEL |
Compression level (1-9) | 6 |
DEDUP_TOOL |
Deduplication tool (hardlink, jdupes, or "") | hardlink |
VERBOSE |
Enable detailed debug output | false |
MAX_BACKUP_SIZE_MB |
Maximum backup size limit | 0 (unlimited) |
EXCLUDE_PATTERNS |
Files/directories to exclude | *.tmp,*.log |
-
Generate fixed salt
openssl rand -hex 8 > fixed_salt.txt chmod 600 fixed_salt.txt -
In
chantik.conf:FIXED_SALT_FILE="/path/to/fixed_salt.txt" DEDUP_TOOL="hardlink"
- In
chantik.conf:INCREMENTAL_ENABLED=false
- In
chantik.conf:NTFY_CUSTOM_SERVER="https://your-ntfy-server.com"
# Perform a full or incremental backup
./chantik.sh
# Test encryption/decryption
./chantik.sh --test
# List all available backups
./chantik.sh --list
# Verify a specific backup
./chantik.sh --verify /path/to/backup.enc
# Verify all backups
./chantik.sh --verify-all
# Restore from a backup
./chantik.sh --restore /path/to/backup.enc
# Run deduplication on backup directory
./chantik.sh --dedup
# Show help
./chantik.sh --helpchantik-backup_YYYYMMDD_HHMMSS/
βββ digital-independence_YYYYMMDD_HHMMSS_full.tar.gz.enc # Full backup
βββ digital-independence_YYYYMMDD_HHMMSS_inc.tar.gz.enc # Incremental backup
βββ volume_postgres_data_YYYYMMDD_HHMMSS_full.tar.gz.enc # Full volume backup
βββ volume_redis_cache_YYYYMMDD_HHMMSS_inc.tar.gz.enc # Incremental volume backup
βββ chantik-backup_YYYYMMDD_HHMM01/
βΒ Β βββ digital-independence_full.tar.gz.enc # Full backup
βΒ Β βββ volume_postgres_data_full.tar.gz.enc # Full backup
βΒ Β βββ volume_redis_cache_full.tar.gz.enc # Full backup
βΒ Β βββ *.checksums # SHA256 checksums
βΒ Β βββ *.enc.checksums # Encrypted file checksums
βββ chantik-backup_YYYYMMDD_HHMM09/
βΒ Β βββ digital-independence_inc.tar.gz.enc # Incremental backup
βΒ Β βββ volume_postgres_data_inc.tar.gz.enc # Incremental volume backup
βΒ Β βββ volume_redis_cache_inc.tar.gz.enc # Incremental volume backup
βΒ Β βββ *.checksums # SHA256 checksums
βΒ Β βββ *.enc.checksums # Encrypted file checksums
- Primary cipher is ChaCha20βPoly1305 (authenticated encryption)
- Fallback cipher is AESβ256βCBC with PBKDF2 key derivation
- Key derivation uses PBKDF2 with configurable iterations (default 600,000)
- Key strength is a 256βbit encryption
- Integrity is ensured by SHA256 checksums for verification
- Every backup is verified for tampering
- Never commit configuration to version control
- Protect encryption key:
chmod 600 encryption.key - Store encryption key separately from backups
- Use strong ntfy.sh tokens
- Regularly rotate encryption keys
- Test restoration periodically
Generate new encryption key:
openssl rand -base64 32 > encryption.key
chmod 600 encryption.keyGenerate fixed salt for deduplication:
openssl rand -hex 8 > fixed_salt.txt
chmod 600 fixed_salt.txtBackup encryption key separately:
gpg -c encryption.keyChantik integrates with ntfy.sh for real-time notifications.
- Get ntfy token: Visit https://ntfy.sh/account
- Choose a topic: Any unique name, e.g.,
my-backup-topic - Configure in chantik.conf:
NTFY_TOPIC="my-backup-topic" NTFY_TOKEN="tk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
| Type | Priority | Tags | When Triggered |
|---|---|---|---|
| Success | 3 (default) | β | Backup completes successfully |
| Error | 5 (urgent) | π΄ | Backup fails or is interrupted |
| Info | 3 | βΉοΈ | Backup starts, configuration loaded |
| Restore | 3 | π | Restore operation completes |
Chantik uses a smart retention policy:
- Daily backups: Keep last 7 days
- Weekly backups: Keep last 4 weeks (one per week)
- Monthly backups: Keep last 6 months (one per month)
# Example retention timeline
Retention: Daily=7, Weekly=4, Monthly=6
# Backups retained:
Day 1-7: All daily backups
Week 1-4: One backup per week
Month 1-6: One backup per month
Older: DeletedChantik can backup and restore Docker volumes:
# In chantik.conf
DOCKER_VOLUMES=(
"postgres_data"
"redis_cache"
"nginx_conf"
)
# Each volume gets its own encrypted backup
volume_postgres_data_20260808_100000_full.tar.gz.enc
volume_redis_cache_20260808_100000_inc.tar.gz.enc# Restore a Docker volume
./chantik.sh --restore /media/backup/chantik-backup_20260808_100000/volume_postgres_data_20260808_100000_full.tar.gz.enc
# Output:
[2026-08-08 10:30:00] π¦ Restoring type: volume_postgres_data
[2026-08-08 10:30:00] π Decrypting volume_postgres_data_20260808_100000_full.tar.gz.enc...
[2026-08-08 10:30:05] β
Checksum verification passed.
[2026-08-08 10:30:05] π¦ Decompressing...
[2026-08-08 10:30:10] π¦ Restoring Docker volume: postgres_data
[2026-08-08 10:30:15] β
Volume restore completed for postgres_data
[2026-08-08 10:30:15] β
Restore completed successfully.# Edit crontab
sudo crontab -e
# Daily backup at 2:00 AM
0 2 * * * /path/to/chantik.sh >> /path/to/backup-cron.log 2>&1
# Weekly full backup on Sunday at 3:00 AM
0 3 * * 0 /path/to/chantik.sh >> /path/to/backup-cron.log 2>&1
# Backup with verbose logging
0 2 * * * VERBOSE=true /path/to/chantik.sh >> /path/to/backup-cron.log 2>&1| Schedule | Cron Expression | Description |
|---|---|---|
| Daily | 0 2 * * * |
Every day at 2:00 AM |
| Hourly | 0 * * * * |
Every hour |
| Weekly | 0 3 * * 0 |
Every Sunday at 3:00 AM |
| Monthly | 0 4 1 * * |
First of every month at 4:00 AM |
ChaCha20 not supported (script will automatically fallback to AES-256-CBC):
β οΈ WARNING: ChaCha20-Poly1305 not supported; falling back to AES-256-CBC.Insufficient disk space:
# Check available space
df -h /media/backup
# Reduce retention or increase storage
RETENTION_DAILY=3
RETENTION_WEEKLY=2Enable verbose mode:
VERBOSE=true ./chantik.shCheck logs:
tail -f chantik.logTest encryption system:
./chantik.sh --test| Scenario | GZIP_LEVEL | PBKDF2_ITERATIONS | INCREMENTAL_ENABLED |
|---|---|---|---|
| Daily backups | 6 | 600000 | true |
| Large files | 3 | 600000 | false |
| Maximum compression | 9 | 600000 | true |
| Speed priority | 1 | 100000 | false |
| Security priority | 6 | 1000000 | true |
Use deduplication with fixed salt:
FIXED_SALT_FILE="/path/to/fixed_salt.txt"
DEDUP_TOOL="hardlink"Use incremental backups:
INCREMENTAL_ENABLED=true
FULL_BACKUP_INTERVAL=14Compress more aggressively:
GZIP_LEVEL=9- ChaCha20-Poly1305 - Authenticated encryption
- OpenSSL - Cryptographic operations
- ntfy.sh - Notification service
- Docker - Container volume backup
- Alpine Linux - Lightweight container image
MIT License - See LICENSE file for details.
- Fork the repository
- Create a feature branch
- Submit a pull request
- π§ Issues: GitHub Issues