Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodump from remote server

We recently ported some data over to MongoDB and are now looking into running daily backups, preferably from a cron job, and restore one of the backups to a secondary mongo database.

Our system is set up as follows:

  • server 1: the development mongo database
  • server 2: two mongo databases, one for staging data and one for production
  • server 3: is where we run all of our cron jobs/batch scripts from.

I checked the mongo docs, and logged into our cron job server and tried to run the following command: (username, host, and password changed for security, I'm not actually connecting to localhost)

mongodump --host 127.0.0.1/development --port 27017 --username user --password pass --out /opt/backup/mongodump-2013-10-07-1 

I get the following messages:

Mon Oct 7 10:03:42 starting new replica set monitor for replica set 127.0.0.1 with seed of development:27017
Mon Oct 7 10:03:42 successfully connected to seed development:27017 for replica set 127.0.0.1
Mon Oct 7 10:03:42 warning: node: development:27017 isn't a part of set: 127.0.0.1 ismaster: { ismaster: true, maxBsonObjectSize: 16777216, ok: 1.0 }
Mon Oct 7 10:03:44 replica set monitor for replica set 127.0.0.1 started, address is 127.0.0.1/
Mon Oct 7 10:03:44 [ReplicaSetMonitorWatcher] starting couldn't connect to [127.0.0.1/development:27017] connect failed to set 127.0.0.1/development:27017

I confirmed that I can connect to the mongo database using mongo -u -p ip/development

Our ultimate goal will be to dump the data from the production database and store it in the staging database. These two databases are both located on the same box, if that makes a difference, but for testing purposes I am just trying to get a backup of development test data.

like image 559
awestover89 Avatar asked Oct 07 '13 15:10

awestover89


People also ask

Where is Mongodump stored?

The mongodump command will overwrite the existing files within the given backup folder. The default location for backups is the dump/ folder. When the WiredTiger storage engine is used in a MongoDB instance, the output will be uncompressed data.

What is Mongodump and Mongorestore?

Database backup is a copy of a database that already exists. In MongoDB, mongodump tool is used to take the data backup. And mongorestore tool is used to restore the backup data.

Which of the following are true differences between Mongoexport and Mongodump?

One of the important differences is that mongodump is faster than mongoexport for backup purposes. Mongodump store data as a binary, whereas, mongoexport store data as a JSON or CSV.


1 Answers

mongo client can parse MongoDB connection string URI, so instead of specifying all connection parameters separately you may pass single connection string URI.

In your case you're trying to pass connection URI as a host, but 127.0.0.1/development is not a valid host name. It means you should specify database parameter separately from the host:

mongodump --host 127.0.0.1 -d development --port 27017 --username user --password pass --out /opt/backup/mongodump-2013-10-07-1 
like image 193
Leonid Beschastny Avatar answered Nov 16 '22 00:11

Leonid Beschastny