How to restore deleted collection

Hello guys,
I accidentally deleted my collection called “inspections” which is under the db sample_training? Would you give me some suggestions that would help me to restore the inspections collection?

If you have inspections dump you can use mongoimport to load that data
Otherwise drop you cluster and create a new one and load entire sample data

I don’t have the inspections dump. Load entire sample data? But I am not sure how to do that? where can I get that whole sample data?


You can drop each database by hand (there are only a few), then go to the . . . button, and select Load Sample Dataset.

Option B

Make sure you don’t have a directory named “inspections” before running:

git clone -b inspections --single-branch inspections

which is a branch I’ve set up.

Below, replace CLUSTER_ID by your = xxxx.yyyy code, and use your username. Then run it.

cd inspections
mongorestore "mongodb+srv://" --username YOU -p  --authenticationDatabase admin --nsInclude sample_training.inspections sample_training/inspections.bson --drop

This takes a few seconds.

Just in case

I don’t recommend it, but you can use mongoimport instead, if you want:

cd inspections
mongoimport "mongodb+srv://" --username YOU -p --authenticationDatabase admin inspections.json

This takes minutes.