'Must specify set name for replica set ConnectionStrings' when using copydb

Viewed 730

I am writing a nodejs script that allows me to copy an entire database to a specified destination host. For this I am using the command copydb.

However I am getting the Error as written above.

I am not sure what to do as I am not using replicas in any way and am not entirely fond of how to use them either. All I want to do is copy the db from source host to destination.

Here is the code:

function copydb(_sourceUrl, _destinationUrl, _db, _sourceAdminUsername, _sourceAdminPassword) {
return new Promise((resolve, reject) => {
    mongoClient.connect(_destinationUrl + "/" + _db)
        .then(destinationDB => {
            destinationDB.admin().command({
                copydb: 1,
                fromhost: _sourceUrl,
                fromdb: _db,
                username: _sourceAdminUsername,
                todb: _db,
                nonce: "some-nonce",
                key: {
                    username: _sourceAdminUsername,
                    password: _sourceAdminPassword
                }
            }, function (err, res) {
                if (err) {
                    reject(err)
                } else {
                    resolve(res)
                }
                destinationDB.close();
            })
        }).catch(err => reject(err))
})

}

The values I am passing are like so:

_sourceUrl: "mongodb://myhost" _desinationUrl: "mongodb://adminuser:adminpassword@localhost:27017" _db: "testdb", _sourceAdminUsername: adminUsername _sourceAdminPassword: adminPassword

PS: I am not sure what to use as nonce field, neither key

0 Answers
Related