How to backup and restore db on Meteor?

I would like to create the menu bar for backup and restore db on my application.
How to backup and restore db on Meteor?
Or have any tool for this?

1 Like

Define a method on server to fetch all the contents using myCollection.find().fetch(), and then save it to somewhere. It should be simple like this. Or use mongobackup?

It mean that use ...find() and write it to file. then read the file and use ...insert() for the restore.
please explain, how to use mongobackup (command line or in JS).

For the CL one, .

I haven’t dealed with Filesystem so much in Meteor yet, but the fs module from node might be a good start?

I am new for Meteor, I came form Laravel PHP Framework.
I am very happy when met Meteor.
I don’t know how to use npmjs package on Meteor.

Simply repackage it using and then add it to your app.

Very thanks, I will try.

what you are looking for is


“This command will create a /dump directory, and store each collection in a separate BSON blob file. This is the best way to backup or transfer databases between systems.” (from @awatson1978’s awesome meteor-cookbook )



to restore and

mongodump --help

for more info.


Great reply, I just used this recently and was going to post the same. Super easy.

For completeness, I just posted a related solution that lets you read from a CSV file. You could easily reverse it and write to a CSV file as well, which would allow you to do any kind of processing you’d like - ignoring fields, encrypting stuff before writing to disk, etc.

Check out

for more.


I’ve just written a quick article for how to quickly back up and restore a Meteor mongo database here (

It’s basically two command lines.

mongodump -h --port 3001 -d


mongorestore -h --port 3001 -d meteor --drop dump/

In terms of how to incorporate it into your app, read the following article for instrucitons on how to run command lines in your application (

I have been working on an open source project, and as part of that wanted to make it easy for the admin of the project to backup his database form the UI vs. the CLI.

i checked out a couple of the mongo-backup solutions out there, but eventually found it quite easy to do myself.

First install ShellJS through npm.

I simply installed it locally with

meteor nom install shelljs --save

Then on the server I created a method called from the UI to run the command

mongodump -h --port 3001 -out <path the user provides> -d meteor

I allow the user to provide a path on the server, and then add the current date time to the end of the path so each backup is kept and date-time stamped.

I additionally created a collection to log the path the backup is in, the date and time it’s made, and who made it.

PLEASE NOTE: This requires that Mongo be installed globally, not just the Mongo from meteor.

On the UI I show the last time the backup was made, and will eventually add the ability to restore a backup if needed.

the project is big, but it’s at if anyone would like to look at it.

The UI portion is under client/layouts/admin/backupBastas

The server portions are in server/myMethods.js and imports/api/bastasDb.js

I hope this helps some of you. Tested on my own machine and was working great (a Mac).

Going to deploy and test on a linux server from a remote machine this weekend.

I’m not a windows user, so not sure it will work the same, but feel free to try and reply.