Created
September 25, 2011 04:12
-
-
Save chsh/1240220 to your computer and use it in GitHub Desktop.
mongo repair script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOCK_FILE=/opt/var/db/mongodb/mongod.lock | |
PID_FILE=/var/run/mongo.pid | |
DAEMON=/opt/mongodb/bin/mongod | |
DBPATH=/opt/var/db/mongodb | |
mongo_running=0 | |
if [ -f $PID_FILE ]; then | |
pid=`cat $PID_FILE` | |
ps auxww | egrep "root +$pid" > /dev/null | |
if [ $? == 0 ]; then | |
mongo_running=1 | |
fi | |
fi | |
if [ $mongo_running == 1 ]; then | |
echo "Mongo already running pid:$pid" | |
exit 0 | |
fi | |
echo "Mongo is not running. Starting to repair." | |
if [ -f $LOCK_FILE ]; then | |
echo -n "Removing lock_file:$LOCK_FILE..." | |
rm $LOCK_FILE | |
echo "done." | |
fi | |
echo "Repairing mongo db at $DBPATH..." | |
$DAEMON --dbpath $DBPATH --repair | |
echo "done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment