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.
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/
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:
Backup:
lvcreate --size 100M --snapshot --name mdb-snap01 /dev/vg0/mongodb
Restore:
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