wesupport

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Percona backup for MongoDB Docker

by | Dec 29, 2022

Wondering how to setup Percona backup for mongodb docker? you are in luck! Our experts have put together this guide to help you get started. Our Docker Support team is here to lend a hand with your queries and issues.

Percona backup for mongodb docker

Today, let us see the steps followed by our support techs to setup Percona backup for mongodb docker.

Step 1 : Launched the Ubuntu 16.04 machine from AWS , then updated the latest packages and installed the docker 

sudo apt-get update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker

Once docker installed with latest package verify the docker version using docker –version 

Step 2 : Installed two docker mongo containers with replica set enabled 

docker run –detach –name datablogs-mongo-primary –volume /var/lib/mongo:/data/db –volume /etc/mongodb.conf:/etc/mongo.conf –publish 44444:27017 mongo –replSet datablogs-repl-set
docker run –detach –name datablogs-mongo-secondary –volume /var/lib/mongo-slave:/data/db –volume /etc/mongodb-slave.conf:/etc/mongo.conf –publish 55555:27017 mongo –replSet datablogs-repl-set

We need to access the mongoDB instances outside the world , so I have publised the mongo db ports with different one

To access the mongoDB , we need to check the IP Address of both containers using below command

docker inspect datablogs-mongo-primary | grep IPAddress
docker inspect datablogs-mongo-secondary | grep IPAddress

— usage of extensions refer with docker help

Step 3 : Configure mongo replica 

We need to login with docker command line and configure and start the replication between mongo servers.

Then, login into primary mongo container and execute below commands in mongo shell ,

docker exec -it datablogs-mongo-primary /bin/bash
config = {“_id” : “datablogs-repl-set”,”members” : [{“_id” : 0,”host” : “172.17.0.2:27017”},{“_id” : 1,”host” : “172.17.0.3:27017”}]};
rs.initiate(config);

Once we initiate the replication primary mongo shell will change.

Step 4 : Install Percona Backup and Configure 

Before proceeding this activity , we need to update and upgrade the packages using apt-get on each mongo containers

Installed the percona backup for mongoDB with below reference URL , we need to follow percona site for proper installation

Once installed the pbm tool , login each mongo containers set storage path and start the pbm agent . I have used local storage path for mongo backup

storage.yaml :
type: filesystem
filesystem:
path: /tmp
pbm store set –config=storage.yaml –mongodb-uri=”mongodb://127.0.0.1:55555/”
pbm-agent –mongodb-uri mongodb://172.17.0.2:27017 &

Step 5 : Backup and restore the collections using pbm 

Once completed the setup running the backup in secondary mongo server

pbm backup –mongodb-uri mongodb://127.0.0.1:27017

Dropped the datablogs db and restored the backup using pbm

Finally verfied the db and collections in primary server

Am Really happy tested percona backup for mongoDB with Docker today

Conclusion

To conclude, our Support Engineers demonstrated how to deploy Percona backup for mongodb docker.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags