Can I use an Ubuntu dump archive on Windows for restoring?


I created used mongodump --archive on our Ubuntu machine (mongo 4.2) and tried to restore it on a Windows Server machine using mongorestore (mongo 4.2) and it is saying:

Failed: stream or file does not appear to be a mongodump archive

Is this possible? To make sure that the archive was valid, I restored it on the Ubuntu machine to a different database and it worked.

Thanks for the help

It should work on Windows
What command you used on Windows
May be some syntax issues/differences between platforms giving that error?

1 Like

Hello @AJ_Keresztes

could you please add the commands you used for mongodump and mongorestore?

As mongorestore restores from the dump/ directory, it creates the database and collections as needed and logs its progress.

mongorestore dump/
Where "dump/ is the folder in which you saved the output from mongodump.


1 Like

Thanks for replies.

Here’s what I used to create the backup (Ubuntu):
mongodump --archive=‘mongodump-dev’ --db=dev --username dev --password pw

Here’s what I’m doing to restore(Windows):
mongorestore --archive=“mongodump-dev” --nsFrom=‘dev.’ --nsTo='apac.

Hello @AJ_Keresztes

so you want to rename while restoring. I doubt that the namespace pattern for --nsFrom and --nsTo will work, just the error message should be a different one than the one you mentioned in your post, You will find details when you follow the link I posted before.

To work around all side effects you can test the following: make a new folder e.g. mydump put the archive in there. Now run
mongorestore --dryRun mydump/
You need to be in the folder which contains the folder mydump/. If you still get the an error please past the full error message here.


Here’s what I’m getting:

If I change the archive to have a bson extension then it just says 0 document(s) restored successfully. 0 document(s) failed to restore.

This worked for me

Created a dump remotely from a DB running on mongodb university cluster

mongodump --uri mongodb+srv:// --archive=test.archive

2020-12-01T10:34:42.574+0530 done dumping test.employee_names (0 documents)
2020-12-01T10:34:42.716+0530 done dumping test.testcoll (1 document)
2020-12-01T10:34:42.814+0530 done dumping test.employee (1 document)
12/01/2020 10:34 AM 1,251 test.archive
Imported into my local instance on my Windows laptop

mongorestore --archive=test.archive --nsFrom “test." --nsTo "testrst.
2020-12-01T10:54:49.366+0530 preparing collections to restore from

2020-12-01T10:54:49.522+0530 finished restoring testrst.employee (1 document)
2020-12-01T10:54:49.523+0530 done

use testrst
switched to db testrst
show collections


Thanks - good to know!

Hello @AJ_Keresztes

may I ask you to show log files or errors as quoted text instead of screenshots? This will help others to better read your issue. You can read up details about this in the Getting Started section
Beside this I like to encourage you to follow my suggestion of the previous post.

mongorestore --dryRun mydump/
As mentioned, this requires that you provide the FOLDER not the FILE in the command

Also your error message says it already: please add .bson to the file name and it should work, or add --archive before the file name, then you can omit the extension.

You can find working examples in documentation of mongorestore which I copied in my previous post.


1 Like

if I do it with the folder, I get:

C:\Program Files\MongoDB\Server\4.2\bin>mongorestore --dryRun --archive=“D:\backup\mongodump-dev"
2020-12-02T09:55:08.120-0500 Failed: CreateFile D:\backup\mongodump-dev”: The filename, directory name, or volume label syntax is incorrect.
2020-12-02T09:55:08.120-0500 0 document(s) restored successfully. 0 document(s) failed to restore.

C:\Program Files\MongoDB\Server\4.2\bin>

still not working

Is your command on a single line?

Quotes could be the issue
Use straight double quotes (")
If i paste your command in a notepad the quotes look different
When i tried the same command on my testdump it works for me

C:\Users\xyz>mongorestore --dryRun --archive=“C:\Users\xyz\test.archive”
2020-12-02T21:57:05.488+0530 preparing collections to restore from
2020-12-02T21:57:05.490+0530 dry run completed

It looks there was some sort of issue transferring the backup to the windows machine. When I created the backup, I used tar/gzip, and I used tar/gzip on the windows machine to extract it.

So, I just manually copied the entire backup (not zipped) to the windows machine and it’s working. I’m not sure why zipping the original didn’t work.

I’m using the following command to restore the databse:

mongorestore --archive="D:\backup\mongodump-dev\mongodump-dev" --nsFrom='dev.*' --nsTo='apac.*'

My goal is to restore from the dev database to apac. Is this the correct command to do this?

@AJ_Keresztes please have a look at the linked documentation mongorestore

cd D:\backup\mongodump-dev\
mongorestore --archive="mongodump-dev" --nsFrom='dev.*' --nsTo='apac.*'

Thanks for your response. I looked the documentation (and stack overflow) and I’ve done the exact thing and it’s restoring to dev, not apac.

I’ve tested this a few times, and it’s ignoring --nsTo (aside from number of asterisks). Not sure why.

Could this be a bug (in mongo 4.2 on Windows)?

It works for me
Can you show few lines from your log?
It would say restoring apac.coll_name from archive…
When you list your Dbs with show dbs are you not seeing apac?

1 Like

Hi, thanks for the reply.

So I already tested a restore and it restored to dev. When I list dbs, there’s a dev one but not apac. Here’s a sample of the output now:

D:\backup\mongodump-dev>mongorestore --archive="mongodump-dev" --nsFrom='dev.*' --nsTo='apac.*'
2020-12-03T09:34:27.268-0500 preparing collections to restore from
2020-12-03T09:34:27.280-0500 restoring to existing collection dev.legacyCoCs without dropping
2020-12-03T09:34:27.280-0500 reading metadata for dev.legacyCoCs from archive ‘mongodump-dev’
2020-12-03T09:34:27.281-0500 restoring dev.legacyCoCs from archive ‘mongodump-dev’
2020-12-03T09:34:27.350-0500 continuing through error: E11000 duplicate key error collection: dev.legacyCoCs index: id dup key: { _id: ObjectId(‘5a4defd9d06f58148cd4087d’) }
2020-12-03T09:34:27.350-0500 continuing through error: E11000 duplicate key error collection: dev.legacyCoCs index: id dup key: { _id: ObjectId(‘5a4defd9d06f58148cd4087e’) }

so it’s still trying to restore to dev for some reason.

It is the quotes which is causing the issue
Please use double quotes for nsFrom & nsTo values
It is behaving differently when you use single quotes


That was it! Thanks!

Mongo DB might want to change the documentation on the web site for mongorestore on windows. It shows restoring using single quotes which doesn’t work.