2

In order to reset replication, I did drop the local mongo database using the following commands:

use local;
db.dropDatabase();

The mongo data directory(dbPath) is /data/db/

I took a backup of this folder before dropping the local database and reinstated the same after issuing db.dropDatabase(). After that restarted mongo service.

Is this the correct way and if not any chance of data loss pertaining to users, DB etc.?

1

Yes and no. Yes, you can do this and your DB is at same state what it was when you took that backup especially if you used journaling. This means of course that everything that you did (changes to the DB) after backup disappears. No part is more like that if you do your backup this way, you should use filesystem snapshots or you should other way prevent disk writing during the copy process.

1
  • "This means of course that everything that you did (changes to the DB) after backup disappears" , Yes this was my intention. Thanks for the reply @JJussi ..
    – John
    Aug 10 '18 at 5:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.