Created
November 4, 2011 14:31
-
-
Save ebot/1339448 to your computer and use it in GitHub Desktop.
Script that compresses all Mongo DBs except admin and local.
This file contains hidden or 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
var hospitals = db.getMongo().getDBNames(); | |
for(var h in hospitals){ | |
if (hospitals[h] != "admin" && hospitals[h] != "local") { | |
var db = db.getMongo().getDB( hospitals[h] ); | |
var size_before = ((db.stats()["dataSize"] / 60) / 60); | |
print( "Repairing DB " + db.getName() + " - " + size_before ); | |
db.repairDatabase(); | |
var size = ((db.stats()["dataSize"] / 60) / 60); | |
print( " Complete - " + size + ". Size reduced by " + ( size_before - size ) + " MB." ); | |
} | |
} | |
print( "Repair Process Complete" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment