pankeshpatel / mDiabetes

This is mDiabetes repository
1 stars 2 forks source link

Add database backup mechanism on AWS #4

Open pankeshpatel opened 2 years ago

pankeshpatel commented 2 years ago

Currently, we have been running our database Server (MongoDB) in docker.

We need to include an automatic backup mechanism of our MongoDB database server using AWS Managed Service/ S3 bucket.

pankeshpatel commented 2 years ago

Write a python/nodejs script that dumps data every day to S3 bucket.

A docker command to dump a database is

sudo docker exec -it  bbba9b7c0c40 sh -c 'mongodump --authenticationDatabase admin -u root -p 123456 --db md-server-db --archive' > db-28-Feb-2022.dump

To verify that database is dumped correctly, please restore database

sudo docker exec -it bbba9b7c0c40 sh -c `mongorestore  --authenticationDatabase admin -u root -p 123456 --db md-server-db --archive' < db-28-Feb-2022.dump

References:

https://dev.to/mkubdev/mongodump-and-mongorestore-with-docker-39m7 https://www.youtube.com/watch?v=DgIC8QdraMM&t=323s

Using nodeJS Server- How to backup mongodb every night - it's really easy. https://www.youtube.com/watch?v=JlM81PN9OP4

pankeshpatel commented 2 years ago

Method # 2 : MongoDB backup on AWS S3 via Cronjob https://www.youtube.com/watch?v=EXvRwOuGpQo