How to configure Percona MongoDB Replicaset, Percona Backup Manager, Backup Agent using Docker and perform Replicaset backup, restore usi...

Search for a command to run...

No comments yet. Be the first to comment.
GitHub 开源项目仓库汇总(2026-04-25 更新) 数据来源:IMA 知识库 GitHub 相关内容整理 | 每周自动更新 本期新增 15 个项目,总计收录 44 个优质开源项目 📊 本周更新亮点 本周新增 15 个项目,重点聚焦 AI Coding 与 MLOps 基础设施: 🤖 AI Coding 全景图:OpenClaw(356K ⭐)、Claude Code(113K ⭐)、opencode(145K ⭐)等领跑赛道 🧠 记忆与持久化:claude-mem(59K ...
从 BoltDB 到 TSDB Single Store:Loki 存储架构演进全景,含阿里云 OSS 配置实战
Step-by-step walkthrough — from zero-downtime backup to production-ready database switch
GitHub 开源项目仓库汇总(2026-04-18 更新) 数据来源:IMA 知识库 GitHub 相关内容整理 | 每周自动更新 本期新增 6 个项目,总计收录 29 个优质开源项目 📊 本周更新亮点 本周新增 6 个项目,包括: AI Coding 多 Agent 协调平台 multica(本周 +5,362 stars) AI 持久记忆框架 MemPalace(43k+ stars) AI 编码工作流编排器 Archon(17k+ stars) 全场景具身机器人数据集 AGIBO...
涵盖 HTTP 客户端、数据处理、爬虫、AI 代理、Obsidian 插件等全类别 Python 工具精选
In this blog post, i will walk you through the steps required to containerize Percona Server for MongoDB, Percona Backup Manager, and Agent from source and configure cloud-native S3(Simple Storage Service) compatible distributed object storage MINIO to backup and restore Percona MongoDB snapshot backups.

Ensure the below binaries are installed before starting the setup and configuration
Docker or Podman to containerize Percona MongoDB replicaset and PBM Agent Docker Compose Golang compiler – Build Percona Backup Manager binaries Portainer (Optional) – Intuitive UI for container configuration and monitoring Let us perform the below steps to set up PSMDB Replicaset; PBM Agent; Minio, S3 compatible bucket, and PBM configuration to perform backups and restores from the bucket.
MONGODB_IMAGE=percona/percona-server-mongodb
MONGODB_VERSION=5.0
MONGO1_PORT=0.0.0.0:15000
MONGO2_PORT=0.0.0.0:15001
MONGO3_PORT=0.0.0.0:15002
MONGODB_PORT=27017
MONGODB_DOCKER_NETWORK=mongo_net
RS_NAME=rs1
$ git clone https://github.com/percona/percona-backup-mongodb.git
ARG MONGODB_VERSION
ARG MONGODB_IMAGE
FROM ${MONGODB_IMAGE}:${MONGODB_VERSION}
USER root
COPY keyFile /opt/keyFile
RUN chown mongodb /opt/keyFile && chmod 400 /opt/keyFile && mkdir -p /home/mongodb/ && chown mongodb /home/mongodb
USER mongodb
version: "3.8"
services:
rs101:
build:
dockerfile: Dockerfile
context: /home/robin/dev/psmdb
args:
- MONGODB_VERSION=${MONGODB_VERSION}
- MONGODB_IMAGE=${MONGODB_IMAGE}
hostname: rs101
labels:
- "com.percona.pbm.app=mongod"
environment:
- REPLSET_NAME=rs1
- MONGO_USER=dba
- BACKUP_USER=bcp
- MONGO_PASS=test1234
ports:
- "${MONGO1_PORT}:${MONGODB_PORT}"
# command: mongod --replSet rs1 --port ${MONGO1_PORT}:27017 --storageEngine wiredTiger --keyFile /opt/keyFile --wiredTigerCacheSizeGB 1
command: ["--replSet", "${RS_NAME}", "--bind_ip_all", "--storageEngine", "wiredTiger" , "--keyFile", "/opt/keyFile"]
volumes:
- data-rs101:/data/db
- ./scripts/start.sh:/opt/start.sh
rs102:
build:
dockerfile: Dockerfile
context: /home/robin/dev/psmdb
args:
- MONGODB_VERSION=${MONGODB_VERSION}
- MONGODB_IMAGE=${MONGODB_IMAGE}
hostname: rs102
labels:
- "com.percona.pbm.app=mongod"
# command: mongod --replSet rs1 --port 27017 --storageEngine wiredTiger --keyFile /opt/keyFile --wiredTigerCacheSizeGB 1
ports:
- "${MONGO2_PORT}:${MONGODB_PORT}"
command: ["--replSet", "${RS_NAME}", "--bind_ip_all", "--storageEngine", "wiredTiger" , "--keyFile", "/opt/keyFile"]
volumes:
- data-rs102:/data/db
rs103:
build:
dockerfile: Dockerfile
context: /home/robin/dev/psmdb
args:
- MONGODB_VERSION=${MONGODB_VERSION}
- MONGODB_IMAGE=${MONGODB_IMAGE}
hostname: rs103
labels:
- "com.percona.pbm.app=mongod"
# command: mongod --replSet rs1 --port 27017 --storageEngine wiredTiger --keyFile /opt/keyFile --wiredTigerCacheSizeGB 1
ports:
- "${MONGO3_PORT}:${MONGODB_PORT}"
command: ["--replSet", "${RS_NAME}", "--bind_ip_all", "--storageEngine", "wiredTiger" , "--keyFile", "/opt/keyFile"]
volumes:
- data-rs103:/data/db
agent-rs101:
container_name: "pbmagent_rs101"
user: "1001"
labels:
- "com.percona.pbm.app=agent"
- "com.percona.pbm.agent.rs=rs1"
environment:
- "PBM_MONGODB_URI=mongodb://${BACKUP_USER:-bcp}:${MONGO_PASS:-test1234}@rs101:27017"
build:
labels:
- "com.percona.pbm.app=agent"
dockerfile: /home/robin/open-source/percona-backup-mongodb/docker/Dockerfile
context: /home/robin/open-source/percona-backup-mongodb/
args:
- MONGODB_VERSION=${MONGODB_VERSION:-5.0}
volumes:
- ./conf:/etc/pbm
- ./backups:/opt/backups
- data-rs101:/data/db
command: pbm-agent
cap_add:
- NET_ADMIN
agent-rs102:
container_name: "pbmagent_rs102"
user: "1001"
labels:
- "com.percona.pbm.app=agent"
- "com.percona.pbm.agent.rs=rs1"
environment:
- "PBM_MONGODB_URI=mongodb://${BACKUP_USER:-bcp}:${MONGO_PASS:-test1234}@rs102:27017"
build:
labels:
- "com.percona.pbm.app=agent"
dockerfile: /home/robin/open-source/percona-backup-mongodb/docker/Dockerfile
context: /home/robin/open-source/percona-backup-mongodb/
args:
- MONGODB_VERSION=${MONGODB_VERSION:-5.0}
volumes:
- ./conf:/etc/pbm
- ./backups:/opt/backups
- data-rs102:/data/db
command: pbm-agent
cap_add:
- NET_ADMIN
agent-rs103:
container_name: "pbmagent_rs103"
user: "1001"
labels:
- "com.percona.pbm.app=agent"
- "com.percona.pbm.agent.rs=rs1"
environment:
- "PBM_MONGODB_URI=mongodb://${BACKUP_USER:-bcp}:${MONGO_PASS:-test1234}@rs103:27017"
build:
labels:
- "com.percona.pbm.app=agent"
dockerfile: /home/robin/open-source/percona-backup-mongodb/docker/Dockerfile
context: /home/robin/open-source/percona-backup-mongodb/
args:
- MONGODB_VERSION=${MONGODB_VERSION:-5.0}
volumes:
- ./conf:/etc/pbm
- ./backups:/opt/backups
- data-rs103:/data/db
command: pbm-agent
cap_add:
- NET_ADMIN
volumes:
backups: null
data-rs101: null
data-rs102: null
data-rs103: null
$ psmdb docker compose -f docker-compose-rs.yaml up -d
[+] Running 8/8
⠿ Container psmdb-rs102-1 Running 0.0s
⠿ Container psmdb-rs103-1 Running 0.0s
⠿ Container pbmagent_rs103 Running 0.0s
⠿ Container pbmagent_rs102 Running 0.0s
⠿ Container psmdb-rs101-1 Running 0.0s
⠿ Container pbmagent_rs101 Running 0.0s
$ mongo "mongodb://dba:test1234@192.168.50.113:15000,192.168.50.113:15001,192.168.50.113:15002/admin?replicaSet=rs1"
$ cd ~/downloads && wget https://dl.min.io/server/minio/release/linux-amd64/minio
$ wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
./mc --help
$ downloads ./minio server /home/robin/data --address=0.0.0.0:7000
API: http://0.0.0.0:7000
RootUser: minioadmin
RootPass: minioadmin
Finished loading IAM sub-system (took 0.0s of 0.0s to load data).
Console: http://192.168.50.113:43859 http://192.168.160.1:43859 http://172.18.0.1:43859 http://172.19.0.1:43859 http://172.24.0.1:43859 http://172.26.0.1:43859 http://172.17.0.1:43859 http://127.0.0.1:43859
RootUser: minioadmin
RootPass: minioadmin
Command-line: https://docs.min.io/docs/minio-client-quickstart-guide
$ mc alias set myminio http://0.0.0.0:7000 minioadmin minioadmin
Documentation: https://docs.min.io
$ mc alias set minio-deb http://192.168.50.113:7000 minioadmin minioadmin
$ mc ls minio-deb
[2022-05-29 14:59:32 IST] 0B nocodb/
[2022-05-29 00:19:41 IST] 0B typesense/
pbm$ mc alias set minio-deb http://192.168.50.113:7000 minioadmin minioadmin
$ mc ls minio-deb
[2022-05-29 14:59:32 IST] 0B nocodb/
[2022-05-29 00:19:41 IST] 0B typesense/
$ sudo apt-get install -y libkrb5-dev
$ cd percona-backup-mongodb
$ make build
$ make install
storage:
type: s3
s3:
endpointUrl: http://192.168.50.113:7000
bucket: pbm
credentials:
access-key-id: "minioadmin"
secret-access-key: "minioadmin"
$ ./pbm config --file /home/robin/dev/psmdb/pbm_config.yaml --mongodb-uri="mongodb://bcp:test1234@192.168.50.113:15000/?replSetName=rs1"
2022-05-29T01:31:14.000+0000 D [resync] got backups list: 02022-05-29T01:31:14.000+0000 D [resync] got physical restores list: 0
$ bin git:(main) ./pbm list --mongodb-uri="mongodb://bcp:test1234@192.168.50.113:15000/?replSetName=rs1"
Backup snapshots:
2022-05-29T01:29:12Z [complete: 2022-05-29T01:29:16Z]
2022-05-29T01:38:38Z [complete: 2022-05-29T01:38:42Z]
2022-05-29T04:04:44Z [complete: 2022-05-29T04:04:48Z]
$ ./pbm backup --mongodb-uri="mongodb://bcp:test1234@192.168.50.113:15000/?replSetName=rs1"
$ ./pbm restore 2022-05-29T04:04:44Z --mongodb-uri="mongodb:/