如何备份和还原Mongodb数据库 [英] How to backup and restore the Mongodb database

查看:195
本文介绍了如何备份和还原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:

http://docs.mongodb.org/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数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆