如何使用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数据库
发布评论