如何备份和还原Mongodb数据库

编程入门 行业动态 更新时间:2024-10-25 16:20:26
本文介绍了如何备份和还原Mongodb数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何使用C#备份和还原Mongodb数据库?目前,只有一台服务器可以保存mongodb数据,并且我想在服务器被破坏的情况下进行备份,以便我可以还原它.

How to use C# to backup and restore the Mongodb database? For now there is only an server to save the mongodb data, and I want to make an backup in case of the server is destroyed so that I can restore it.

有人知道如何使用C#做到这一点吗?

Dose anybody know how to do that using C#?

推荐答案

如果您只想要自动备份,则有一种比采用成熟的编程语言更简单的方法:

If you just want automated backups, there is an easier way than resorting to a full-fledged programming language:

docs.mongodb/manual /tutorial/backup-databases-with-filesystem-snapshots/

如链接中所示,以下命令就足够了.您可以将其放在statup-script/daemon中以常规频率执行:

As shown in the link, the below command would suffice. You may put it in a statup-script/daemon to execute it at regular frequencies:

备份:

lvcreate --size 100M --snapshot --name mdb-snap01 /dev/vg0/mongodb

还原:

lvcreate --size 1G --name mdb-new vg0 gzip -d -c mdb-snap01.gz | dd of=/dev/vg0/mdb-new mount /dev/vg0/mdb-new /srv/mongodb

更多推荐

如何备份和还原Mongodb数据库

本文发布于:2023-10-24 17:24:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524551.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:备份   数据库   Mongodb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!