This Helm chart automates the process of MongoDB backup (using mongodump) and restore (using mongorestore) between two MongoDB instances.
mongo-backup-restore/
βββ templates/
β βββ mongo-dump-pod.yaml # Pod that performs mongodump
β βββ mongo-restore-pod.yaml # Pod used for restoring data
βββ values.yaml # Source and destination MongoDB URIs
βββ Chart.yaml # Helm chart definition
βββ deploy-mongo-backup-restore.sh # Bash script to automate the process
Edit the values.yaml file to specify the source and destination MongoDB connection strings:
source:
uri: "mongodb://<user>:<password>@<source-host>:27017/"
restore:
namespace: "ferretdb"
uri: "mongodb://<user>:<password>@<target-host>:27017/?socketTimeoutMS=300000&connectTimeoutMS=300000"- Make sure
helm,kubectl, andyqare installed. - Deploy and run the backup/restore process:
chmod +x deploy-mongo-backup-restore.sh
./deploy-mongo-backup-restore.sh- The dump pod writes data to
/dumpand keeps running so you can copy files. - The restore pod just runs with mongodb client to connect to target database later and dump the data.
- You can extend this with Kubernetes Jobs for fully automated lifecycle.
- Helm 3+
- Kubernetes cluster
- MongoDB access
yqinstalled (brew install yqorapt install yq)