Revert effects of faulty update through and only through mongo shell

I searched as much as possible but found lesser and lesser.

Problem statement:

some update actions has done on mogo db or an specific collection.
we have oplog which contains any update.
what can I do without exiting from the environment through a somple process, preferable a single query update revert the effect of faulty update.

  1. there are point in time restore which I do not like. the process if faulty itself and complex. there are some correct updates after faulty update which should still remain. then I should remove them from oplog and apply oplog without time restriction.
  2. the oplog replay impose some unnecessery procedures like creating an standby DB and do repairements there(strange design)
  3. oplog ops manager is just creating a layer of complexity over data layer and also is not avaiable on comunity edition.

so in breif how I can revert effect of some updates through mongo shell and have data avaiable again as long as it does not contradict later changes made on collections

Welcome to the MongoDB Community @Kamran !

If you are connecting directly to your MongoDB deployment there is no generic “undo” for database updates. This is true for all databases as far as I’m aware: once changes have been committed they are not expected to be reversible, so you would need to have appropriate backup policies and data access controls for your use case.

The typical approach would be restoring from a backup or from another copy of data before modification (for example, using a Delayed Replica Set Member). The complexity of recovering will depend on the operation(s) you are trying to revert.

If you are directly making changes that may have unexpected outcomes, I would always test first in a representative development or staging environment so you reduce the risk of having to recover from an update gone awry in your production environment.

Regards,
Stennie

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.