How to Export and Import Mongodb from Meteor App?


#1

Hello
Is there a good way to export and import MongoDB from Meteor App? Or is there a good way to backup and restore MongDB from Meteor App?


#2

Yep! When Meteor is running, make sure you’re in your app’s root folder and type:

$ mongodump --port=3001 -o ../dump

The ../ is so it dumps it outside your Meteor folder (in case Meteor tries to parse it).

To restore a dump folder to your Meteor app:

$ mongorestore --port=3001 <dump folder name>

To clear out the destination first:

$ mongorestore --drop --port=3001 <dump folder name>

#3

I want to create like a webpage for backup and restore mongodb from client, not on cmd or terminal.


#4

Is it possible to read or find from MongoDB and save it to a file for backup purpose, and read from that file and insert it back to the database for restore purpose?


#5

Not entirely sure but to do this client-side I believe you will have to make the function available via Meteor.functions and then do Meteor.call.


#7

mongodump is not installed as part of the Meteor installation. If you want to use it you will need to install it separately. For example in Ubuntu 16:

sudo apt install mongodb-clients

#8

@phirum, I used an npm package called ShellJS. In conjunction with installing full MongoDB on the server where the Meteor / Mongo is running.

Then using the mongodump command through ShellJS i allow my end user to provide a path on the server to save a backup, append a date and time to it in the background, and run the mongodump command on a button click in the meteor UI.

Works quite well. I haven’t added the restore bit yet, but will do that this year using the same technique.

Feel free to look at what I did. The code is open source on github.

I hope this helps,


#9

To make it easier to locate here is where the code is at in the project…sorry for the extra post.

https://github.com/LBBLUG/meteorBastas/tree/master/client/layouts/admin/backupBastas

And on the server side


#10

I’d also like to revise my original post, because I forgot the option -d meteor so that dump/restore uses the meteor database.


#11

I followed the solution above to mongodump and mongorestore the DB, but I am getting the following message in the console when I run mongorestore:

connected to: 127.0.0.1:3001
assertion: 17370 Restoring users and roles is only supported for clusters with auth schema versions 1 or 3, found: 5

I am currently using the latest version of meteor (1.4.4.1), with all the latest packages on Ubuntu.

Also when I run:


 mongodump --port=3001 -d meteor -o ../dump

I get the following:

connected to: 127.0.0.1:3001
2017-04-25T13:20:34.317-0400 DATABASE: meteor	 to 	../dump/meteor

But when looking in that …/dump/meteor folder, it seems empty.

Any suggestions on what might be done to make it work? Thanks in advance for any advice :slight_smile:


#12

In one of my earlier demo projects I used https://github.com/hitchcott/app-dump, I think by @hitchcott. Worked quite well, but probably not recommended for production. Looks like it’s not been updated for a while so not sure if it works with modern meteor versions. I think it requires that the MongoDB is hosted on the same server but I could be wrong.

If you can’t use that directly, then the source code might give you some pointers. At the bottom of the readme are credits to mongodb-backup and mongodb-restore…


#13

Hi,

I have exactly the same problem…
Have you managed to solve it somehow?

TIA


#14

Try this:


#15

Herteby is right, Studio 3t is THE BOMB for mongodb admin. It does EVERYTHING.


#16

You could try MongoBooster


#17

Same issue. Any breakthrough?


#18

Sorry, I haven’t found a solution.


#19

Guys. Studio 3T. It’s like SqlYog for Mongo…

Get it. Don’t be silly.


#20

Is there anyway to backup data without running meteor? Like, I’m unable to run meteor, so I want to backup data and reset meteor. I know that meteor store data in .meteor/local/db


#21

Yeaaaaah it’s stored on your hdd, there are some command lines you can run to start mongo without Meteor.