18

This is a question that was asked before, but I have tried all solutions, and simply cannot get it right. I have spent quite some time researching before posting this question. I have looked at the official MongoDB documents and many other blogs.

How to restore a .wt MongoDB backup file to a local MongoDB database?

Saketh
  • 323
  • 1
  • 3
  • 5

3 Answers3

7

There is a much simpler way, But here are few things that need to consider, you can not create a backup from a single .wt file, you have to use the entire folder.

The easiest way is to start mongod with dbpath

mongod --dbpath <path-to-you-backup-folder-where-all-.wt-files-resides>

If your mongod service is already running, you will get some error or the above command will not work. So make sure to stop any existing mongod service if running, and then run the above command. After that simply connect to your localhost mongo server, and this DB will be visible. Hopefully this will works!

5

You can restore your .wt WiredTiger files downloaded from your Atlas Backup (which unzips or untar as a restore folder) to your local MongoDB.

First, make a backup of your /data/db path. Call it /data_20200407/db. Second, copy paste all the .wt files from your Atlas Backup restore folder into your local /data/db path. Restart your Ubuntu or MongoDB server. Start your Mongo shell and you should have those restored files there.

Yi Xiang Chong
  • 151
  • 1
  • 2
4

Community wiki answer:

*.wt are binary data files used by the WiredTiger storage engine. Individual files are not usable as a standalone backup. If you want to take a file copy backup of a MongoDB dbPath you need to include all of the files using a Supported File Copy Backup Method.

If you have a valid file backup you can use it as the dbPath for another mongod instance. Aside from copying files, there is no restore special restore process for a file copy backup.

Can you clarify what files you have in your backup?