mongodb - Mongo compare and import missing data -


i have mongo server receiving data servers behind amazon lb, 2 days ago there error , part of servers sent data old mongo server had db of same name, realized , fixed right away.

now have part of data stored on wrong machine. need way compare data between 2 dbs (which each have 2 relevant collections) , insert missing data correct collection.

i not care unique id mongo gives need compare field "uuid" create.

mongo version: 2.4.4

i new mongo , appreciated.

yes, can. follow these steps...

1 mongoexport , mongoimport on basis of fields on want compare , import.

  1. mongoexport --db db_name --collection collection_name --type csv --fields field1,field2,field3 --out /var/www/export.csv

once exported csv @ specified location. open , remove unwanted fields...

  1. mongoimport --db db_name --collection collection_name --type csv --file /var/www/export.csv --fields field1,field2,field3 --upsertfields field1,field2,field3

note:
1. if working in production environment, dealing huge database free mongo load of queries , export else might stucked.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -