How to find failed documents when dumping a collection

27 views
Skip to first unread message

Haris Osmanagic

unread,
Apr 18, 2016, 6:16:34 AM4/18/16
to mongodb-user
Hi all!

Here is the use case for my first question here:

I am removing historical data from a collection in MongoDB (3.2), but first I need a backup of it. The choice has fallen, a simple combination of:

1. mongodump --db myDatabase --collection myCollection -q <my query> --archive --gzip
2. db.myCollection.remove(<my query>)

So far so good. However, I must not remove any data which is not backed up. So, I need one of the following:
1. IDs of documents which could not be dumped
2. IDs of document could be dumped

Is there anyway I can get this?

Thanks a lot for the great thing called MongoDB and thanks in advance for the answer!

Haris

Ankur Raina

unread,
May 19, 2016, 1:19:07 AM5/19/16
to mongodb-user

Hi Haris,

  1. IDs of documents which could not be dumped

Mongodump will dump all the documents up to the time when mongodump was executed. If you require a Point in Time Backup, you may consider using the —oplog option. However, mongodump won’t return the _ids of documents which could/couldn’t be dumped.

One way to verify your mongodump output is to restore this backup to other server and compare the _ids (preferrably using some script) to get the documents which got inserted after the mongodump run and hence couldn’t be backed up. This process assumes that there are no inserts/updates between the time mongodump was called and the verification process.

Regards
Ankur

Reply all
Reply to author
Forward
0 new messages