Skip to content

Instantly share code, notes, and snippets.

@porn
Created August 29, 2016 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porn/6ed41962c45135e7fe4f6d8cb67fcbc8 to your computer and use it in GitHub Desktop.
Save porn/6ed41962c45135e7fe4f6d8cb67fcbc8 to your computer and use it in GitHub Desktop.
script for forcing initial resync of mongo secondary
#!/bin/bash
# this script is intended for forcing initial resync of mongo secondary
read -p "This will DELETE ALL data on the machine! If you wish to continue then type: 'sure'> "
if [[ ! $REPLY == 'sure' ]]
then
echo "Okay, bye!"
exit 1
fi
echo
echo "* Stopping mongo service"
sudo service mongod stop
sleep 3
echo "* Deleting the content of /var/lib/mongodb/"
rm -rf /var/lib/mongodb/*
echo "* Starting mongo service"
sudo service mongod start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment