Question :
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.?
Answer :
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.