Proper way of backing up a Docker Volume used by MongoDB

Dear friends,
I migrated my microservice using MongoDB as its permanence layer to a Docker Compose dockerized solution.
The architecture has an official MongoDB 6 container running which is using a Volume (not a bind mount to the host filesystem as before).

I am reading several approaches to backing up daily but am unsure of the best practice to follow.

Ideally I want to setup a daily cron, stop the app and/or freeze the DB, perform a mongodump on a mounted bind directory, then resume normal operations, all of which possibly with a log for failures.

Any suggestions or better approaches? thanks a lot in advance

PS What I like about archive dump is the ease of transferring them to another host possibily running a non dockerized mongodb and restoring there

Nothing really changes because it is running in a container.

All the backup methods still apply.

Filesystem snapshots are one of the easiest to execute and the quickest to restore but that will be reliant on your underlying storage or platform.

Mongodump does not scale well as the deployment grows in size as well as the potential performance impact mentioned in the manual. Restoring will build the indexes fresh as they are not included in the mongodump, this can take a considerable amount of time.

Whatever you chose make sure you regularly test it to ensure it is valid and to know if it meets your Recovery Time Objective or not.

2 Likes