Importing Mongo dump to local (macos) - naturalcrit/homebrewery GitHub Wiki

7/29/2025 CalculusChild did an export from Mongo Atlas of our database, something that I think is actually referred to as a "snapshot". It was a big gzip file, or abc.tar.gz file extension, and contained .wt or "wireTiger" files.

This data dump is not used by mongorestore. So that documentation won't work for importing the DB into a local mongo db.

Here is what I did, warts and all.

!! Be sure you have the same Mongo version as the live Homebrewery site is using at the time of the data export. At this time, that was Mongo Community 6.0.

!! Note that I am using MacOS with the Homebrew package manager. Any commands that start with brew stem from that package manager. And it shouldn't be confused for the Homebrewery.

1. Find the file path of your current database.

You can do that with the mongo terminal. You need to have Mongo running, and then run this command:

db.serverCmdLineOpts()

Which should get you output that looks somewhat like this:

{
  argv: [
    '/opt/homebrew/opt/[email protected]/bin/mongod',
    '--config',
    '/opt/homebrew/etc/mongod.conf'
  ],
  parsed: {
    config: '/opt/homebrew/etc/mongod.conf',
    net: { bindIp: '127.0.0.1, ::1', ipv6: true },
    storage: { dbPath: '/opt/homebrew/var/mongodb' },
    systemLog: {
      destination: 'file',
      logAppend: true,
      path: '/opt/homebrew/var/log/mongodb/mongo.log'
    }
  },
  ok: 1
}

The file path of your database is in the parsed.storage.dbPath property. For me, on MacOS, it's /opt/homebrew/var/mongodb. Keep in mind that these directories might be 'hidden directories', not immediately viewable in a file explorer application.

Note, or open, that directory so have you it available.

2. Stop your Mongo service

Stop any mongo service you have running currently. Keep in mind that Mongo typically runs all the time in the background, starting when your computer boots up. So just double check it is stopped.

For me, with MacOS and using the Homebrew package manager, I can do this:

brew services list

Which will give me an output like:

Name                  Status  User      File
colima                started Me ~/Library/LaunchAgents/homebrew.mxcl.colima.plist
mongodb-community     none              
[email protected] none              
[email protected] started Me ~/Library/LaunchAgents/[email protected]
postgresql@14         none              
redis                 none              
unbound               none   

I can see that i have a few different installations of mongo and some other stuff, and that Mongo 6.0 is currently running. I want to shut that down with:

brew services stop mongodb/brew/[email protected]

3. Paste downloaded db into current db folder, or into new directory

This is where things split between what I did, and what might be possible. What I did was paste the downloaded db contents into the current db directory, overwriting everything that was already there. I did this because I didn't care what was in my original db. If you want to preserve that old data, you may be able to create a new db location by creating a new folder, pasting your downloaded data there. Either way, I think the subsequent steps are likely roughly the same.

To be clear, starting with the tar.gz file, I uncompressed it (on Mac, using Archive Utility) and then copied all the inner contents of that and pasted them into /opt/homebrew/var/mongodb and overwriting all. If i wanted to preserve the old stuff, I would try pasting into /opt/homebrew/var/mongodb-2.

4. Reset the db path and start Mongo service

To reset the db path, I did this:

mongod --dbpath /opt/homebrew/var/mongodb --repair

Followed by restarting the mongo service:

brew services start [email protected]

And checking the status with:

brew services list

And hoping it says "started" and not "error".

5. Use Mongo Compass to connect

At this point I switched to Mongo Compass GUI to connect the server and check that I could connect, and look for the db name I needed to connect to. As downloaded, the database name that I had to point towards was heroku_cjpfxl1z, not homebrewery as I had earlier (and is the suggested name in the Homebrewery github repo readme when creating the mongo server initially).

6. Update the mongodb_uri location

The downloaded db data may use a different database name than what you previously had. For example, when first setting up Homebrewery locally on your machine the readme.md suggests using "homebrewery" as the name of the database. The app uses this as the default name it expects. But in my case, the db downloaded from Atlas had the name heroku_cjpfxl1z. So I need to update that in the app.

Up to this point all of my app configuration was done in /config/default.json. Now, I duplicated that file and renamed it /config/local.json and added a line for the mongodb_uri property:

// config/local.json
{

"host" : "homebrewery.local.naturalcrit.com:8000",

"naturalcrit_url" : "local.naturalcrit.com:8010",

"secret" : "secret",

"web_port" : 8000,

"enable_v3" : true,

"enable_themes" : true,

"local_environments" : ["docker", "local"],

"publicUrl" : "https://homebrewery.naturalcrit.com",

"hb_images" : null,

"hb_fonts" : null,

"mongodb_uri" : "mongodb://127.0.0.1/heroku_cjpfxl1z"

}

Now I can set that db path separate from the rest of the code base-- local.json is included in the .gitignore file so changes here don't get uploaded to Github.

7. Restart app

At this point I could start up my homebrewery app and it would connect.


I had a problem where the Vault wouldn't search because of an issue with a missing text index for title query, which seems odd-- it seems like that should be a part of the export of the live site mongo db. Especially since there are plenty of Indexes that came with it. But I just added a text index for title and it worked again.