https://github.com/glensc/docker-mongodb-hotbackup
MongoDB Hot Backup for Docker
https://github.com/glensc/docker-mongodb-hotbackup
docker hot-backup mongodb percona percona-mongodb
Last synced: 2 months ago
JSON representation
MongoDB Hot Backup for Docker
- Host: GitHub
- URL: https://github.com/glensc/docker-mongodb-hotbackup
- Owner: glensc
- License: mit
- Created: 2018-01-24T14:25:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-21T20:16:01.000Z (about 6 years ago)
- Last Synced: 2025-01-24T08:25:18.269Z (4 months ago)
- Topics: docker, hot-backup, mongodb, percona, percona-mongodb
- Language: Shell
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MongoDB Hot Backup for Docker
# Usage
This project provides script to run [Hot Backup](#hot-backup) for [percona/percona-server-mongodb].
The `mongo` container needs to be setup with local mount:
```yml
version: "3"services:
mongo:
image: percona/percona-server-mongodb:3.4
# (case sensitive) engine: mmapv1, rocksdb, wiredTiger, inMemory
command: --storageEngine=wiredTiger
volumes:
- /srv/backups/mongodb:/backup
ports:
- 27017:27017# vim:ts=2:sw=2:et
```To run the backup, specify container name or id on commandline:
```
./backup-mongodb.sh CONTAINER BACKUP_DIR [USER] [PASSWORD]
```- `CONTAINER` can be id, name, label, or swarm service name
- `BACKUP_DIR` is path that is bind mounted into container: `-v $EXTERNAL_BACKUP_DIR:$CONTAINER_BACKUP_DIR` the value for local dir is detected automatically
- `USER` mongodb username, optional (will try to autheticate only when filled)
- `PASSWORD` mongodb password, optional[percona/percona-server-mongodb]: https://hub.docker.com/r/percona/percona-server-mongodb/
## Hot Backup
[Percona Server for MongoDB] includes an integrated open-source hot backup system for the default [WiredTiger] and alternative [MongoRocks] storage engine. It creates a physical data backup on a running server without notable performance and operating degradation.
[Percona Server for MongoDB]: https://www.percona.com/software/mongo-database/percona-server-for-mongodb
[WiredTiger]: https://docs.mongodb.org/manual/core/wiredtiger/
[MongoRocks]: https://www.percona.com/doc/percona-server-for-mongodb/LATEST/mongorocks.html#mongorocksTo take a hot backup of the database in your current `dbpath`, run the `createBackup` command as administrator on the `admin` database and specify the backup directory.
```
> use admin
switched to db admin
> db.runCommand({createBackup: 1, backupDir: "/my/backup/data/path"})
{ "ok" : 1 }
```If the backup was successful, you should receive an `{ "ok" : 1 }` object. If there was an error, you will receive a failing `ok` status with the error message, for example:
```
> db.runCommand({createBackup: 1, backupDir: ""})
{ "ok" : 0, "errmsg" : "Destination path must be absolute" }
```https://www.percona.com/doc/percona-server-for-mongodb/LATEST/hot-backup.html