Operations

Backups

All Cleanmails data lives in a single SQLite file. Backups are as simple as copying one file.

Database Location

text
/opt/cleanmails/data/cleanmails.db

Manual Backup

bash
cp /opt/cleanmails/data/cleanmails.db /backups/cleanmails-$(date +%Y%m%d).db

Automated Daily Backup (Cron)

bash
# Add to crontab (crontab -e)
0 3 * * * cp /opt/cleanmails/data/cleanmails.db /backups/cleanmails-$(date +\%Y\%m\%d).db

This runs at 3 AM daily and creates a dated backup file.

Restoring from Backup

bash
# Stop the service
docker compose down

# Replace the database
cp /backups/cleanmails-20240101.db /opt/cleanmails/data/cleanmails.db

# Restart
docker compose up -d
Stop before restoring

Always stop Cleanmails before replacing the database file. Writing to a SQLite file while it's in use can cause corruption.

What's Included

The SQLite database contains everything:

  • Users and sessions
  • Campaigns, steps, and delivery logs
  • Lead lists and all leads
  • Senders and domains (including encrypted passwords)
  • Workspaces and settings
  • Newsletter forms and subscribers
  • License information
  • Integration configs and webhook subscriptions
  • AI chat history

What's NOT in the Database

  • Uploaded files — Logos and bonus files in /uploads/
  • Mail server data — Stored in Docker volumes (mail-data, mail-state)
  • SSL certificates — Stored in Caddy's volume (caddy-data)

For a complete backup, also copy the uploads/ directory and export Docker volumes.

Backup Retention

Keep at least 7 days of backups. Clean up old ones with:

bash
# Delete backups older than 30 days
find /backups -name "cleanmails-*.db" -mtime +30 -delete