Re: Imcomplete Restore

22 views
Skip to first unread message

gregor

unread,
Nov 7, 2012, 10:52:56 AM11/7/12
to mongod...@googlegroups.com
So after you have modified the data and done the mongorestore you expect this?

{
  "_id" : 1,
  "av" : 101,
  "cost" : 50,
}
{
  "_id" : 2,
  "av" : 101,
  "cost" : 75,
}

{
  "_id" : 3,
  "av" : 101,
  "cost" : 50,
}

{
  "_id" : 4,
  "av" : 101,
  "cost" : 750,
}

On Wednesday, November 7, 2012 2:51:06 PM UTC, pascal lemay wrote:
Hi,

I have a problem with my mongorestore.
I have a replica set with 1 primary, 2 secondary. 1 passive and 1 arbiter

I took a complete backup of my DB on my passive mongo instance :

mongodump --oplog --journal

If a drop my db  on the primary and restore the backup :

mongorestore --journal --oplogReplay /dump

The backup is restored correctly (no problem). So if I don't drop the database and apply some modification to the collection like an insert, drop and/or update and I try to restore the backup to the current DB, I don't have any error so if I verify the data,  all the data in the database as the same of before the restore (the updated data).

// Original data (Backup data)
{
  "_id" : 1,
  "av" : 101,
  "cost" : 50,
}

{
  "_id" : 2,
  "av" : 101,
  "cost" : 50,
}

{
  "_id" : 3,
  "av" : 101,
  "cost" : 50,
}

// Updated data

// _id 1 is removed
{      //Updated
  "_id" : 2,
  "av" : 101,
  "cost" : 75,
}

{
  "_id" : 3,
  "av" : 101,
  "cost" : 50,
}

{        //added
  "_id" : 4,
  "av" : 101,
  "cost" : 750,
}


// Restored data (????? not equal to the backup data)

{
  "_id" : 2,
  "av" : 101,
  "cost" : 75,
}

{
  "_id" : 3,
  "av" : 101,
  "cost" : 50,
}

{
  "_id" : 4,
  "av" : 101,
  "cost" : 750,
}


Best regards

pascal lemay

unread,
Nov 7, 2012, 11:18:42 AM11/7/12
to mongod...@googlegroups.com
I expect to return to the original state (backup) :


{
  "_id" : 1,
  "av" : 101,
  "cost" : 50,
}

{
  "_id" : 2,
  "av" : 101,
  "cost" : 50,
}

{
  "_id" : 3,
  "av" : 101,
  "cost" : 50,
}

gregor

unread,
Nov 8, 2012, 10:45:59 AM11/8/12
to mongod...@googlegroups.com
That won't happen -  you should get what I said.  mongorestore only performs inserts into the existing database, and does not perform updates or upserts. If existing data with the same _id already exists on the target database, mongorestore will not replace it.


However you don't seem to be getting that - are you getting an errors from mongorestore.?

gregor

unread,
Nov 8, 2012, 10:47:12 AM11/8/12
to mongod...@googlegroups.com
Assuming I am correct in understanding that you are trying to do a restore without dropping the database?

pascal lemay

unread,
Nov 9, 2012, 8:56:00 AM11/9/12
to mongod...@googlegroups.com
Yes, I try to restore without dropping my database.

So if I understand, I need to drop before restore if I want to have a complete restore.

Thx for your help, your documentation is very useful.
Reply all
Reply to author
Forward
0 new messages