Search code examples
mongodbshelldockermongodump

Calling mongodump wrapped into docker


My setup is as follows:

  • there is a mongodb replica set (v. 2.4.8), which I like to backup via mongodump
  • there is a machine (NAS) outside the replica set, which should perform the the backup task, but does not have the mongodump binary installed. But it has docker support.

So there is my idea to use docker to perform the mongodump on the NAS. A shell script "mongodump.sh" should wrap the docker call to mongodump with all needed params and I would call it like:

mongodump.sh --host rs/url -u backup -p "password" --out ./dump/

Is this possible with docker? What would the shell script look like?


Solution

  • If found the solution. The command I use to perform the mongodump via docker ist:

    docker run --rm --name some-mongo -v /volume1/Backups/mongodump:/dumps --entrypoint mongodump mongo --host rs1/myserver.net -u backup -p "password" --out /dumps