diff options
Diffstat (limited to 'db/cloner.cpp')
-rw-r--r-- | db/cloner.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/db/cloner.cpp b/db/cloner.cpp index fd86e10b787..74a22659909 100644 --- a/db/cloner.cpp +++ b/db/cloner.cpp @@ -62,6 +62,8 @@ namespace mongo { for example repairDatabase need not use it. */ void setConnection( DBClientWithCommands *c ) { conn.reset( c ); } + + /** copy the entire database */ bool go(const char *masterHost, string& errmsg, const string& fromdb, bool logForRepl, bool slaveOk, bool useReplAuth, bool snapshot, bool mayYield, bool mayBeInterrupted, int *errCode = 0); bool copyCollection( const string& from , const string& ns , const BSONObj& query , string& errmsg , bool mayYield, bool mayBeInterrupted, bool copyIndexes = true, bool logForRepl = true ); @@ -564,9 +566,10 @@ namespace mongo { virtual LockType locktype() const { return WRITE; } virtual void help( stringstream &help ) const { help << "copy a database from another host to this host\n"; - help << "usage: {copydb: 1, fromhost: <hostname>, fromdb: <db>, todb: <db>[, username: <username>, nonce: <nonce>, key: <key>]}"; + help << "usage: {copydb: 1, fromhost: <hostname>, fromdb: <db>, todb: <db>[, slaveOk: <bool>, username: <username>, nonce: <nonce>, key: <key>]}"; } virtual bool run(const string& dbname, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) { + bool slaveOk = cmdObj["slaveOk"].trueValue(); string fromhost = cmdObj.getStringField("fromhost"); if ( fromhost.empty() ) { /* copy from self */ @@ -597,7 +600,7 @@ namespace mongo { c.setConnection( authConn_.release() ); } Client::Context ctx(todb); - bool res = c.go(fromhost.c_str(), errmsg, fromdb, /*logForReplication=*/!fromRepl, /*slaveok*/false, /*replauth*/false, /*snapshot*/true, /*mayYield*/true, /*mayBeInterrupted*/ false); + bool res = c.go(fromhost.c_str(), errmsg, fromdb, /*logForReplication=*/!fromRepl, slaveOk, /*replauth*/false, /*snapshot*/true, /*mayYield*/true, /*mayBeInterrupted*/ false); return res; } } cmdcopydb; |