summaryrefslogtreecommitdiff
path: root/db/cloner.cpp
diff options
context:
space:
mode:
authorDwight <dwight@10gen.com>2010-05-18 15:08:32 -0400
committerDwight <dwight@10gen.com>2010-05-18 15:08:32 -0400
commit0f96d0434764ac833050ddba50f0d1548e31cda7 (patch)
treedb97946df7913c2053019c8343351c7c969cf7c7 /db/cloner.cpp
parent18dfee2cb0661180e67118730855c960b0dbea42 (diff)
downloadmongo-0f96d0434764ac833050ddba50f0d1548e31cda7.tar.gz
better cloneCollection help
Diffstat (limited to 'db/cloner.cpp')
-rw-r--r--db/cloner.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/db/cloner.cpp b/db/cloner.cpp
index d3a4dd419af..2d2193f6a77 100644
--- a/db/cloner.cpp
+++ b/db/cloner.cpp
@@ -442,7 +442,11 @@ namespace mongo {
virtual LockType locktype() const { return WRITE; }
CmdCloneCollection() : Command("cloneCollection") { }
virtual void help( stringstream &help ) const {
- help << "{ cloneCollection: <collection ns>, from: <hostname>, query: <query> }";
+ help << "{ cloneCollection: <namespace>, from: <host> [,query: <query_filter>] [,copyIndexes:<bool>] }"
+ "\nCopies a collection from one server to another. Do not use on a single server as the destination "
+ "is placed at the same db.collection (namespace) as the source.\n"
+ "Warning: the local copy of 'ns' is emptied before the copying begins. Any existing data will be lost there."
+ ;
}
virtual bool run(const string& dbname , BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
string fromhost = cmdObj.getStringField("from");
@@ -450,9 +454,16 @@ namespace mongo {
errmsg = "missing 'from' parameter";
return false;
}
+ {
+ HostAndPort h(fromhost);
+ if( h.isLocalHost() ) {
+ errmsg = "can't copy from self";
+ return false;
+ }
+ }
string collection = cmdObj.getStringField("cloneCollection");
if ( collection.empty() ) {
- errmsg = "missing cloneCollection spec";
+ errmsg = "bad 'cloneCollection' value";
return false;
}
BSONObj query = cmdObj.getObjectField("query");