Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SERVER-6961 Added system.indexes.bson back to mongodump for pre 2.2 m…

…ongorestore
  • Loading branch information...
commit 9541d2b83dd35deb023cf307a0d494951bd0e40b 1 parent 6e96617
@Zarkantho Zarkantho authored
Showing with 13 additions and 3 deletions.
  1. +5 −2 src/mongo/tools/dump.cpp
  2. +8 −1 src/mongo/tools/restore.cpp
View
7 src/mongo/tools/dump.cpp
@@ -218,9 +218,12 @@ class Dump : public Tool {
error() << "Cannot dump " << name << ". Collection has '/' or null in the collection name." << endl;
continue;
}
-
- // Don't dump indexes
+
if ( endsWith(name.c_str(), ".system.indexes") ) {
+ // Create system.indexes.bson for compatibility with pre 2.2 mongorestore
+ const string filename = name.substr( db.size() + 1 );
+ writeCollectionFile( name.c_str() , outdir / ( filename + ".bson" ) );
+ // Don't dump indexes as *.metadata.json
continue;
}
View
9 src/mongo/tools/restore.cpp
@@ -177,6 +177,7 @@ class Restore : public BSONTool {
}
void drillDown( boost::filesystem::path root, bool use_db, bool use_coll, bool top_level=false ) {
+ bool json_metadata = false;
LOG(2) << "drillDown: " << root.string() << endl;
// skip hidden files and directories
@@ -209,6 +210,11 @@ class Restore : public BSONTool {
}
}
+ // Ignore system.indexes.bson if we have *.metadata.json files
+ if ( endsWith( p.string().c_str() , ".metadata.json" ) ) {
+ json_metadata = true;
+ }
+
// don't insert oplog
if (top_level && !use_db && p.leaf() == "oplog.bson")
continue;
@@ -220,8 +226,9 @@ class Restore : public BSONTool {
}
}
- if (!indexes.empty())
+ if (!indexes.empty() && !json_metadata) {
drillDown(indexes, use_db, use_coll);
+ }
return;
}
Please sign in to comment.
Something went wrong with that request. Please try again.