Skip to content

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

  1. Frequency: Perform regular backups (daily or based on business needs).
  2. Destination: Use secure, external storage (e.g., cloud storage, NAS, or offsite servers).
  3. Automation: Backup process could be automated by the system itself, talk to the product team about it.
  4. Testing: Periodically restore from backups to ensure reliability.
  5. 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 --gzip
docker cp <mongodb_container_name>:/data/backup/mongodump.archive ./backups/mongodump.archive

3. Backup Configuration Files

Copy app configuration files to the backup directory:

docker cp <app_container_name>:/path/to/config ./backups/config

4. Compress and Store Backup

Compress the backup directory for storage:

tar -czvf backup-$(date +%F).tar.gz ./backups
mv backup-*.tar.gz /path/to/storage/location

5. 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.gz

6. 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