This guide covers setting up automated backups for StaticSend using S3-compatible storage and Coolify cron jobs.
The backup script (backup.sh) creates compressed backups of your StaticSend database and uploads them to S3-compatible storage. It includes:
- SQLite database backup using safe
.backupcommand - Automatic compression and timestamping
- S3-compatible storage upload (AWS S3, DigitalOcean Spaces, etc.)
- Optional Cronivore monitoring integration
- Automatic cleanup of old backups (30+ days)
- S3-compatible storage bucket
- AWS CLI installed in your container/server
- Coolify cron job capability
Add these environment variables to your Coolify deployment:
S3_ENDPOINT=https://s3.amazonaws.com # or your S3-compatible endpoint
S3_BUCKET=your-backup-bucket
S3_ACCESS_KEY=your-s3-access-key
S3_SECRET_KEY=your-s3-secret-key
S3_REGION=us-east-1DATABASE_PATH=/app/data/staticsend.db # Default path
CLEANUP_OLD_BACKUPS=true # Auto-delete backups older than 30 daysCRONIVORE_CHECK_SLUG=your-check-slug # Get from cronivore.com
CRONIVORE_URL=https://cronivore.com # Default URLS3_ENDPOINT=https://s3.amazonaws.com
S3_REGION=us-east-1 # Your actual regionS3_ENDPOINT=https://nyc3.digitaloceanspaces.com # Your region
S3_REGION=us-east-1 # Required by AWS CLIS3_ENDPOINT=https://s3.us-west-002.backblazeb2.com # Your region
S3_REGION=us-west-002S3_ENDPOINT=https://s3.wasabisys.com
S3_REGION=us-east-1- Go to your StaticSend resource in Coolify
- Navigate to "Scheduled Tasks" or "Cron Jobs"
- Create a new cron job with:
# Schedule: 0 2 * * * (2 AM daily)
# Command:
/app/backup.sh# Schedule: 0 2 * * 0 (2 AM every Sunday)
# Command:
/app/backup.shThe backup script requires these tools in your container:
sqlite3- For database backupawsCLI - For S3 uploadcurl- For Cronivore monitoring- Standard Unix tools (
tar,gzip,find, etc.)
These are already included in the StaticSend Docker image.
Backups are stored with this naming convention:
staticsend-backup-YYYY-MM-DD-HHMMSS.tar.gz
Example: staticsend-backup-2025-09-07-020000.tar.gz
Cronivore provides monitoring for your backup jobs:
- Create account at cronivore.com
- Create a new check for your backup job
- Copy the check slug from the URL
- Set environment variables:
CRONIVORE_CHECK_SLUG=your-check-slug-here
The script will automatically:
- Ping "start" when backup begins
- Ping "success" when backup completes
- Ping "fail" if any error occurs
Test your backup configuration:
# SSH into your Coolify server or container
docker exec -it your-staticsend-container /app/backup.shExpected output:
StaticSend backup starting...
Database path: /app/data/staticsend.db
Database size: 2.1M
Creating backup: staticsend-2025-09-07-140000.db
Creating compressed archive: staticsend-backup-2025-09-07-140000.tar.gz
Archive size: 512K
Uploading staticsend-backup-2025-09-07-140000.tar.gz to S3 bucket 'your-bucket'...
Backup upload complete: staticsend-backup-2025-09-07-140000.tar.gz (512K)
StaticSend backup script finished successfully.
To restore from a backup:
-
Download backup from S3:
aws s3 cp s3://your-bucket/staticsend-backup-YYYY-MM-DD-HHMMSS.tar.gz . \ --endpoint-url https://your-s3-endpoint -
Extract the backup:
tar -xzf staticsend-backup-YYYY-MM-DD-HHMMSS.tar.gz
-
Stop StaticSend application
-
Replace database file:
cp staticsend-YYYY-MM-DD-HHMMSS.db /app/data/staticsend.db
-
Restart StaticSend application
"Missing required S3 environment variables"
- Verify all S3_* environment variables are set in Coolify
- Check for typos in variable names
"Database file not found"
- Verify DATABASE_PATH points to correct location
- Ensure persistent storage is properly mounted
"AWS CLI command not found"
- Ensure you're using the official StaticSend Docker image
- AWS CLI is pre-installed in the container
"Permission denied"
- Check that backup.sh is executable:
chmod +x backup.sh - Verify container has write access to temporary directories
S3 Upload Fails
- Test S3 credentials manually with AWS CLI
- Verify S3_ENDPOINT URL is correct
- Check bucket permissions and policies
For detailed debugging, run the script manually:
set -x # Enable debug mode
/app/backup.sh- S3 Credentials: Use IAM users with minimal required permissions
- Bucket Policies: Restrict access to backup bucket
- Encryption: Enable S3 bucket encryption
- Access Logs: Monitor S3 access logs for unauthorized access
- Rotation: Regularly rotate S3 access keys
The script automatically cleans up backups older than 30 days. To modify retention:
# Keep backups for 90 days (modify the script)
CUTOFF_DATE=$(date -d '90 days ago' +%Y-%m-%d)
# Disable cleanup entirely
CLEANUP_OLD_BACKUPS=false- Use S3 Intelligent Tiering for automatic cost optimization
- Consider using cheaper storage classes for older backups
- Monitor storage costs and adjust retention as needed
- Use compression (already enabled in the script)