Using command prompt to MongoDB dump and restore

*** Find the Primary Server, on any web server open command prompt as Administrator and run the following command:

mongo --port 27017Then run the following command: rs.status().

  • Create Folder: E:\Mongo_Backup\BeforeUpdate.
  • Backup the MongoDB database using the Mongo Dump command that follows or use the Script in the MongoDB Backup_ Restore.zip file: mongodump --port=27017--db=syracuse --out=E:\Mongo_Backup\BeforeUpdate\.
  • Once the backup is complete Stop All Mongo Services.
  • Uninstall MongoDB on all three servers from Control Panel →Programs and Features.
  • Delete all MongoDB Services on all three servers using the following command:Sc delete “Service Name”(Include the quotes).
  • Clear the Configdb Folders on the server E:\Sage\MongoDB\data\configdb.
  • Clear the db Folders on the server E:\Sage\MongoDB\data\db.
  • Clear the log Folders on the server E:\Sage\MongoDB\log.
  • Run Installation for MongoDB version 3.6 on the server (Ensure to install the binary files to E:\Sage\MongoDB\Server\).

 

  • Open a second command prompt window as Administrator and run the following commands on ERPWeb01:

mongo --port 27018

rs.initiate()

rs.add("ERPWeb02:27018")

rs.add("ERPWeb03:27018")

rs.slaveOk()

rs.status()This command is just to check the Status of the DB cluster

exit

 

  • Go back to the second command prompt window and run the following commands on ERPWeb01:

mongo --port 27019

rs.initiate()

rs.add("ERPWeb02:27019")

rs.add("ERPWeb03:27019")

rs.status()This command is just to check the Status of the Configuration

exit

 

  1. Start on Web Server 1 and change all MongoDB Services to start with the correct Service account. The services will have to be restarted for the change to take effect.
  2. Restore the MongoDB database backup using the Mongo restore command that follows or use the Script in the MongoDB Backup_ Restore.zip file: (PS. This must be done on the PRIMARY MongoDB server so the database backup might need to be copied to another server)
  3. mongorestore --port=27017 --db=syracuse E:\Temp\Mongo\syracuse –drop
  4. Use RoboMongo(RoboT3) installed on Web Server 1 to connect to the MongoDB database on port 27017 and check few containers to make sure the data is present (e.g. Users, Solution, etc)
  5. At this point keep the Syracuse services stopped
  6. Upgrade the Elastic Search Component on the web server
  7. Upgrade the Syracuse Component on the web server.
  8. The Syracuse update will take very long as it will apply the MongoDB database content updates
  9. The Syracuse Services will automatically start after each one is upgraded but DO NOT LOG INTO Syracuse UNTIL THE APPLICATION LAYER UPDATES ARE DONE.
  10. Once all components have been updated, log into Syracuse using the Reference folder endpoint only