In the mongodb docker page there's the following tutorial on how to dump a mongodb collection:
sudo docker exec container_name sh -c 'exec mongodump -d collection_name --archive' > /home/mongo_backup/all-collections.archive
I thougth of creating another container which runs this dump periodically (twice a day for example) and saves to a folder that is mounted inside it. But can I mongodump
from a container that is not the container that has the collections? Can I mongodump
via local network?
After this is solved, there's still the problem of where to send this backup. It can't be on the same place as my code deployed because it can be erased accidentaly.
Is this a good backup strategy? Any better ideas?
I thougth of creating another container which runs this dump periodically [...] there's still the problem of where to send this backup
mgob
- "MongoDB dockerized backup agent" does just that: it's a container running mongodump
periodically with features to upload generated dump to various Clouds, S3 and SFTP.
We've been using it for some time both with Docker and Kubernetes with good results.