[英]How can I perform incremental backup for MongoDB which is not replicaset( StandAlone) on Azure Kubernetes Services(AKS)?
I have setup mongodb on Kube.netes cluster on Azure(AKS), and I am not sure where will be the conf file for changes.我在 Azure (AKS) 上的 Kube.netes 集群上设置了 mongodb,我不确定更改的 conf 文件在哪里。 I want to setup incremental backup for this deployment on AKS, its showing me
error "2022-03-08T10:21:54.536+0000 namespace with DB local and collection oplog.rs does not exist".
我想在 AKS 上为此部署设置增量备份,它向我显示
error "2022-03-08T10:21:54.536+0000 namespace with DB local and collection oplog.rs does not exist".
Please help me with incremental backups on standalone Mongodb Server.请帮助我在独立的 Mongodb 服务器上进行增量备份。 I am using mongodump command as
- mongodump --host=xx.xx.xx.xx --port 27017 -d local -c oplog.rs -u username --authenticationDatabase admin -p password --out="/var/opt/baclup"
我正在使用 mongodump 命令作为
- mongodump --host=xx.xx.xx.xx --port 27017 -d local -c oplog.rs -u username --authenticationDatabase admin -p password --out="/var/opt/baclup"
Is there any way without changing to Replicaset?有什么办法不改成 Replicaset 吗?
Also, how do I know where MongoDB is installed on the pod?另外,我怎么知道 pod 上安装了MongoDB的位置?
You can take the backup using different ways Manual, Port-forward, Cronjobs您可以使用不同的方式进行备份手动、端口转发、Cronjobs
Go inside the POD of mongodb and run the command Go 在 mongodb 的 POD 中并运行命令
kubectl exec -it <mongodb-pod-name> -- mongodump --out ./mongodb/backup <Update your command as per need >
or或者
kubectl exec -it <mongodb-pod-name> -- mongodump --dbpath /data/db --out ./mongodb/backup
Or collection backup或者收藏备份
kubectl exec -it <mongodb-pod-name> -- mongodump --collection MYCOLLECTION --db DB_NAME --out ./mongodb/backup
Proxy the port to local machine将端口代理到本地机器
kubectl port-forward svc/mongodb 27027
mongodump --collection MYCOLLECTION --db DB_NAME --out -u USERNAME -p ./mongodb-backup
Cronjob will hit the MongoDb service save the backup and upload it to GCP bucket or S3 bucket you can configure as per need. Cronjob 将命中 MongoDb 服务保存备份并将其上传到 GCP 存储桶或 S3 存储桶,您可以根据需要配置。
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: mongodb-backup
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: mongodb-backup
image: mongo:4.4.0-bionic
args:
- "/bin/sh"
- "-c"
- "/usr/bin/mongodump -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD -o /tmp/backup -h mongodb"
- "tar cvzf mongodb-backup.tar.gz /tmp/backup"
#- gsutil cp mongodb-backup.tar.gz gs://my-project/backups/mongodb-backup.tar.gz
envFrom:
- secretRef:
name: mongodb-secret
volumeMounts:
- name: mongodb-persistent-storage
mountPath: /data/db
restartPolicy: OnFailure
volumes:
- name: mongodb-persistent-storage
persistentVolumeClaim:
claimName: mongodb-pv-claim
Ref: https://www.cloudytuts.com/tutorials/kube.netes/how-to-backup-and-restore-mongodb-deployment-on-kube.netes/参考: https://www.cloudytuts.com/tutorials/kube.netes/how-to-backup-and-restore-mongodb-deployment-on-kube.netes/
Also, how do i know where MongoDB is installed on the pod?
另外,我怎么知道 pod 上安装了 MongoDB 的位置?
Is there any way without changing to Replicaset?有什么办法不改成 Replicaset 吗?
If you know Replica set thn you know the answer of above question.如果你知道副本集,那么你就会知道上述问题的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.