# MongoDB Backup & Restore
# Overview
This chapter introduces how to backup and restore GROWI data using weseek/mongodb-awesome-backup (opens new window).
# Requirements
- Docker
- AWS S3 bucket to upload backup files
- Access key and secret key for a user authorized to access S3 bucket.
# Using AWS S3
# Before You Start
To backup/restore MongoDBs, weseek/mongodb-awesome-backup (opens new window) creates a temporary container that executes shell scripts. In order to access the MongoDB server from the temporary container, add the docker command option below.
# When MongoDB Is Running as a Docker Container
Run a command to find out the container name, and add an option --link ${container}:mongo
with the container name (${container}
).
# e.g.
Use docker ps
to find out the container name.
vagrant@ubuntu-xenial:/etc/docker-compose$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
21a10f879cba mongo "docker-entrypoint.s…" 11 minutes ago Up 11 minutes 27017/tcp serene_swartz
man
The command above shows the container name is serene_swartzman
, therefore the option is --link serene_swartz:mongo
.
# When MongoDB Is NOT Running as a Docker Container
# When Docker Host is Linux
Add --network host
to use the same network with the host.
# For Docker for Mac
- (TBD: Looking for a contributor)
# For Docker for Windows
- (TBD: Looking for a contributor)
# How to Backup
- Run weseek/mongodb-awesome-backup (opens new window) container with (
--rm
) flag.docker run --rm \ -e MONGODB_HOST=<Target MongoDB Host> \ -e AWS_ACCESS_KEY_ID=<Your IAM Access Key ID> \ -e AWS_SECRET_ACCESS_KEY=<Your IAM Secret Access Key> \ -e S3_TARGET_BUCKET_URL=<Target S3 Bucket URL (s3://...)> \ weseek/mongodb-awesome-backup
- The command creates a backup for all databases in the target MongoDB server, and upload it as
backup-YYYYMMdd.tar.bz2
in the S3 bucket.
TIP
See weseek/mongodb-awesome-backup (opens new window) for more options.
# How to Restore
- Run weseek/mongodb-awesome-backup (opens new window) container with (
--rm
) flag.docker run --rm \ -e MONGODB_HOST=<Target MongoDB Host> \ -e AWS_ACCESS_KEY_ID=<Your IAM Access Key ID> \ -e AWS_SECRET_ACCESS_KEY=<Your IAM Secret Access Key> \ -e S3_TARGET_BUCKET_URL=<Target S3 Bucket URL (s3://...)> \ -e S3_TARGET_FILE=backup-YYYYMMdd.tar.bz2 \ weseek/mongodb-awesome-backup restore
- The command restores the specified file (
backup-YYYYMMdd.tar.bz2
in the example above ) in the S3 bucket. - Restart GROWI.
TIP
See weseek/mongodb-awesome-backup (opens new window) for more options.
# Using Google Cloud Platform
- (TBD: Looking for a contributor)