Backing Up Reitti
Reitti stores all your location data, visits, and trips in a PostgreSQL database. The only component that needs to be backed up is this database, as all other data can be regenerated or reconfigured.
What Needs to Be Backed Up
Database Only - All your location tracking data, processed visits, trips, and user settings are stored in the PostgreSQL database. The application code and configuration can be easily restored from your deployment setup.
Creating Database Backups
Since Reitti typically runs with PostgreSQL in a Docker Compose stack, you can create backups using the following commands:
Full Database Backup
docker compose exec postgis pg_dump -U postgres -d reitti > backup_$(date +%Y%m%d_%H%M%S).sql
Compressed Backup (Recommended)
docker compose exec postgis pg_dump -U postgres -d reitti | gzip > backup_$(date +%Y%m%d_%H%M%S).sql.gz
Custom Format Backup (Fastest Restore)
docker compose exec postgis pg_dump -U postgres -d reitti -Fc > backup_$(date +%Y%m%d_%H%M%S).dump
Restoring from Backup
From SQL Backup
docker compose exec -T postgis psql -U postgres -d reitti < backup_20240101_120000.sql
From Compressed SQL Backup
gunzip -c backup_20240101_120000.sql.gz | docker compose exec -T postgis psql -U postgres -d reitti
From Custom Format Backup
docker compose exec -T postgis pg_restore -U postgres -d reitti -c backup_20240101_120000.dump
Automated Backup Strategy
Consider setting up automated backups using a cron job:
# Add to crontab for daily backups at 2 AM
0 2 * * * cd /path/to/reitti && docker compose exec postgis pg_dump -U postgres -d reitti | gzip > /backup/path/reitti_$(date +\%Y\%m\%d).sql.gz
Best Practices
- Regular Schedule: Set up automated daily or weekly backups
- Multiple Locations: Store backups in different locations (local, cloud storage)
- Test Restores: Periodically test your backup restoration process
- Retention Policy: Keep multiple backup versions but clean up old ones to save space
- Monitor Size: Track backup file sizes to detect potential issues
Storage Considerations
Location tracking data can grow significantly over time. Monitor your backup sizes and consider:
- Compressing backups to save storage space
- Implementing backup rotation to manage disk usage
- Using incremental backups for very large datasets