Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Latest commit

 

History

History
104 lines (86 loc) · 3.11 KB

README.md

File metadata and controls

104 lines (86 loc) · 3.11 KB

mongorestore-s3

dockeri.co

IMPORTANT: This is a fork of snic/mongorestore-s3 which is a fork of Drivetech/mongorestore-s3

Docker Image with Alpine Linux, mongorestore and awscli for restore mongo backup from s3

Use

Restore complete database from backup 2016-09-20_06-00-00_UTC.gz in s3

docker run -d --name mongorestore \
  -v /tmp/backup:/backup
  -e "BACKUP_NAMES=2016-09-20_06-00-00_UTC.gz"
  -e "MONGO_URI=mongodb://user:pass@host:port/dbname"
  -e "AWS_ACCESS_KEY_ID=your_aws_access_key"
  -e "AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key"
  -e "AWS_DEFAULT_REGION=us-west-1"
  -e "S3_BUCKET=your_aws_bucket"
  atlascloud/mongorestore-s3

Restore only collections collection1 and collection2 from backup 2016-09-20_06-00-00_UTC.gz in s3

docker run -d --name mongorestore \
  -v /tmp/backup:/backup
  -e "BACKUP_NAMES=2016-09-20_06-00-00_UTC.gz"
  -e "MONGO_URI=mongodb://user:pass@host:port/dbname"
  -e "AWS_ACCESS_KEY_ID=your_aws_access_key"
  -e "AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key"
  -e "AWS_DEFAULT_REGION=us-west-1"
  -e "S3_BUCKET=your_aws_bucket"
  -e "COLLECTIONS=collection1,collection2"
  atlascloud/mongorestore-s3

Restore complete database from backup 2016-09-20_06-00-00_UTC.gz in s3 with "--noIndexRestore"

docker run -d --name mongorestore \
  -v /tmp/backup:/backup
  -e "BACKUP_NAMES=2016-09-20_06-00-00_UTC.gz"
  -e "MONGO_URI=mongodb://user:pass@host:port/dbname"
  -e "AWS_ACCESS_KEY_ID=your_aws_access_key"
  -e "AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key"
  -e "AWS_DEFAULT_REGION=us-west-1"
  -e "S3_BUCKET=your_aws_bucket"
  -e EXTRA="--noIndexRestore"
  atlascloud/mongorestore-s3

Use Kubernetes

  1. Customize the file kub "kub_cronjob.yaml" for his needs.
  2. Run kubectl apply -f ./kub_cronjob.yaml in the repository directory.
  3. done 🙂

IAM Policity

You need to add a user with the following policies. Be sure to change your_bucket by the correct.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1412062044000",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:PutObjectAcl"
            ],
            "Resource": [
                "arn:aws:s3:::your_bucket/*"
            ]
        },
        {
            "Sid": "Stmt1412062128000",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::your_bucket"
            ]
        }
    ]
}

Extra environmnet

  • S3_PATH - Default value is mongodb. Example s3://your_bucket/mongodb/
  • EXTRA - Default not set. Set extra parameters that are passed to mongorestore
  • BACKUP_PATH - Local path inside /backup where the backups are located. Useful for tar files with some directory structure

License

MIT