This guide covers backing up and restoring CVAT data for self-hosted deployments.
Source: site/content/en/docs/administration/community/advanced/backup_guide.md
CVAT Data Volumes
CVAT uses Docker volumes to persist data. Understanding these volumes is essential for backup and restore operations.
Defined in docker-compose.yml:421-428:
Volume Descriptions
Full Backup Procedure
Step 1: Stop All CVAT Containers
Stop all containers to ensure data consistency:
If you’re using additional compose files (e.g., docker-compose.override.yml):
Step 2: Create Backup Directory
Step 3: Backup Core Data
Backup the three essential volumes:
Backup PostgreSQL Database
Backup ClickHouse Analytics Database
Step 4: Verify Backups
Confirm all backup archives were created:
Expected output:
Step 5: Restart CVAT
Optional Backups
Depending on your needs, you may also want to backup:
Backup Django Keys
Backup Logs
Backup Redis Cache
Automated Backup Script
Create a backup script (backup_cvat.sh):
Make it executable:
Schedule Automatic Backups
Add to crontab for daily backups at 2 AM:
Add line:
Restore Procedure
Use the exact same CVAT version when restoring. Database schemas change between versions. After restoring, you can upgrade CVAT, which will migrate the database automatically.
Step 1: Verify CVAT Installation
Ensure CVAT is installed and containers exist:
If containers don’t exist, run initial setup first:
Step 2: Stop All Containers
Step 3: Restore Data from Backups
Navigate to your backup directory:
Restore PostgreSQL Database
Restore ClickHouse Database
Step 4: Start CVAT
Step 5: Verify Restoration
Check logs to ensure services started correctly:
Access the web interface and verify:
- Users can log in
- Projects and tasks are visible
- Media files load correctly
- Analytics data is available (if applicable)
Database-Only Backup (PostgreSQL)
For more efficient database backups using PostgreSQL tools:
Using pg_dump
Create Backup
Restore from Backup
Using pg_dumpall (includes users and roles)
Create Backup
Restore from Backup
Backup to Remote Storage
Amazon S3
Rsync to Remote Server
Backup Retention Policy
Example script to keep only the last 7 daily backups:
Add to crontab to run daily:
Disaster Recovery Checklist
- Document your setup: Keep notes on CVAT version, customizations, and configuration
- Test restores regularly: Verify backups work before you need them
- Store backups offsite: Use remote storage for critical data
- Backup configuration files: Include
docker-compose.yml, .env, custom settings
- Version compatibility: Match CVAT version during restore
- SSL certificates: Backup certificates if using HTTPS
- Custom integrations: Document any custom scripts or integrations
Troubleshooting
Backup Issues
Issue: Permission denied during backup
Solution: Ensure the backup directory is writable:
Issue: Container not found
Solution: Check container names:
Restore Issues
Issue: Database restore fails with version mismatch
Solution: Use the same CVAT version as the backup, then upgrade:
Issue: Data directory not empty
Solution: Remove existing data before restore:
Additional Resources