Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 290

How to restore a mongodump that's one single file

$
0
0

A few months ago I did a dump of my mongodump db and it resulted in a single file instead of multiple bson and json files:

![enter image description here

I tried to restore it using:

mongorestore --drop --db lodeep dump

dump is the folder containing the file but I get this:

enter image description here

I don't remember how exactly I made this dump. And why it's not like the usual dump. And why the file has no extension. I'm a bit lost. I really need this data.

When I do this:

head mongodump-prod-db

I see that it's indeed my database and its collections:
enter image description here

Any help please?


I remembered now I used this command to dump it:

mongodump --uri'mongodb+srv://XXXX:XXXXXXXXX@cluster0.fklgt.mongodb.net/DB_NAME'--archive="mongodump-prod-db" --forceTableScan

And if I want to restore it to the cloud, I do this:

mongorestore --uri'mongodb+srv://XXXX:XXXXXXXXX@cluster0.fklgt.mongodb.net/DB_NAME'--archive="mongodump-prod-db" --nsFrom='DB_NAME.' --nsTo='copy_new_db.'

I tried to restore it locally:

mongorestore --uri 'mongodb://localhost:27017/<local_dbname>'--archive="mongodump-prod-db"

But it results in this:
enter image description here


I also tried to restore it to the cloud:

mongorestore --uri'mongodb+srv://XXXXXX:XXXXXXXXX@cluster0.mchmj.mongodb.net/myDatabase'--archive="mongodump-prod-db" --nsFrom='myDatabase.originalCollection' --nsTo='myDatabase.copy_new_collection'

And I see this:
enter image description here


I tried this:

mongorestore --archive="mongodump-prod-db" --db restoreddb --verbose

It shows it's reading collections names but then it restores nothing:

2024-10-06T16:05:45.499+0200    using write concern: &{majority <nil> 0s}2024-10-06T16:05:45.524+0200    The --db and --collection flags are deprecated for this use-case; please use --nsInclude instead, i.e. with --nsInclude=${DATABASE}.${COLLECTION}2024-10-06T16:05:45.551+0200    archive prelude <dbname>.users2024-10-06T16:05:45.560+0200    archive prelude <dbname>.badges2024-10-06T16:05:45.631+0200    preparing collections to restore from2024-10-06T16:06:16.228+0200    0 document(s) restored successfully. 0 document(s) failed to restore.

Viewing all articles
Browse latest Browse all 290

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>