Backup process
Overview
Depends on the deployment setup, backup process might differ a lot, however the principle almost not changing. The app configuration has to be stored, system database and any other external resources (if used).
Backup Strategy
- Frequency: Perform regular backups (daily or based on business needs).
- Destination: Use secure, external storage (e.g., cloud storage, NAS, or offsite servers).
- Automation: Backup process could be automated by the system itself, talk to the product team about it.
- Testing: Periodically restore from backups to ensure reliability.
- Retention Policy: Retain backups for a defined period based on organizational requirements.
Steps to Organize Backup Process
1. Stop Necessary Services (if applicable)
Ensure the safety of the data by stopping containers or putting the database in a safe state.
2. Backup MongoDB
Export the MongoDB database using the mongodump utility:
docker exec <mongodb_container_name> mongodump --archive=/data/backup/mongodump.archive --gzipdocker cp <mongodb_container_name>:/data/backup/mongodump.archive ./backups/mongodump.archive3. Backup Configuration Files
Copy app configuration files to the backup directory:
docker cp <app_container_name>:/path/to/config ./backups/config4. Compress and Store Backup
Compress the backup directory for storage:
tar -czvf backup-$(date +%F).tar.gz ./backupsmv backup-*.tar.gz /path/to/storage/location5. Secure Backups
Ensure backups are encrypted before transferring them to external storage. Use tools like GPG:
gpg --symmetric --cipher-algo AES256 backup-$(date +%F).tar.gz6. Periodic Restoration Test
Test the backup restoration process regularly to validate its effectiveness:
docker exec -i <mongodb_container_name> mongorestore --archive=/path/to/mongodump.archive --gzip