Getting Started
What is MongoDB?
Install / Config
C.R.U.D. Ops
Data Modeling
Database Mgmt
MongoDB Database Management
Backup Procedures
How do you backup a database?
.
mongodump
Backing up the
dbpath
folder
From the
mongo
shell:
Copy local database:
db.copyDatabase()
Copy remote database:
db.cloneDatabase()
OR: use a replica set!
How do you restore data?
.
mongorestore
Restoring up the
dbpath
folder
How do you backup a single collection
.
Command line:
mongoexport -d db-name -c collection-name --out export-file [--csv]
From the
mongo
shell:
db.cloneCollection()
How do you restore a single collection
.
Command line:
mongoimport -d db-name -c collection-name --file export-file --type csv|json [--headerline]
How do you repair data?
.
Login as a database admin
use db-name
db.repairDatabase()
How can sharding and replication affect backups?
.
Backing up and restoring individual shards or members of a replica set can pose problems
Make sure you backup or restore the
entire
database on that server
If possible, make sure no write operations are taking place
+
o
-