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.
- 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...
- 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
Post a Comment