Mongo Collections gone


#1

I wake up to the server hung and all my collections are now empty. Is there any back up or any way to get the data back without manually reentering all the info. Also I am new to coding and meteor both started about a month ago. If there is already a topic about this please let me know I have been looking for a while and can’t find any info.


#2

Was this a development project or a deployed meteor build project?


#3

I did not like putting my project up with the deploy command so I going to say it is a development project.


#4

You can deploy your project anywhere. It does not have to be deployed on meteor.com

The trouble with the development environment is, running meteor reset or any other number of things will delete your collections.

When you deploy an application to your own infrastructure be sure to manage your database and back it up.

Unfortunately your data is gone.


#5

If you have test-data etc you’d like to enter in for a “fresh” install with the right data, put it in your startup code.

if (Meteor.isServer) {
  Meteor.startup(function () {
    if(MyCollection.find().count() === 0){
      MyCollection.insert({someData: "nice"});
      MyCollection.insert({someData: "somemorenicedata"});
    }
  }
}

This is exceptionally nice for users

if (Meteor.users.find().count() === 0) {
  Accounts.createUser({
    username: "greblak",
    password: "test"
  }
}

A “meteor reset” will drop your data, however it will be back up again on starting the server if you have it specified in your boot file :slight_smile:


#6

So. . . . I ended up learning what you guys have said the hard way. But to make sure this dose not happen again I have installed meteor-backup-restore and added the HTML tag of {{> backupRestoreControls}} on one of my pages for now. I will clean this up and make it so the server can save the data once a day. but for now I have re-entered all the data that was lost. Thank you all for your help. I have over 100 things that need to be added to the collection so i can’t just add it to the code to have it remade at startup, but I do have some other smaller collections that I can do this with. It is a great Idea and dose help me solve another problem that I was going to come to later in in this project.


#7

I’m curious if you were using replica sets. If so, did you mongo collections disappear from all nodes?


#8

It sounds like the app was in development mode. In which case a local mongodb only.