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

Scheduled PostgreSQL backups to AWS S3

License

Notifications You must be signed in to change notification settings

ImpactMapper/postgresql-to-s3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL S3 Backups

This docker image starts an hourly cron job.

The cron job creates a backup of the PostgreSQL database and uploads it to S3.

Usage

Build the container using

$ docker build ./ -t im/rds_backups

The container can be executed manually using

$ docker run -it im/rds_backups

Please mind the configuration below.

Execution role policy

The execution role needs an S3 IAM policy.

An example looks like:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
          "s3:Put*",
      ],
      "Resource": [
        "arn:aws:s3:::${s3_bucket_arn}",
        "arn:aws:s3:::${s3_bucket_arn}/*"
      ]
    }
  ]
}

s3_bucket_arn, the ARN of the bucket to upload the backup to.

Environment

The container requires the following environment variables to be set:

  • POSTGRES_DATABASE, name of the database
  • POSTGRES_HOST, the name of the RDS instance
  • POSTGRES_PORT, the port of the RDS instance (default: 5432)
  • POSTGRES_USER, the database user
  • POSTGRES_PASSWORD, the database user password
  • S3_BUCKET, the name of the S3 bucket to upload the backup to
  • S3_PREFIX, prefix which will be prepended to the upload path (default: backups)

Two words of caution

Please test your backups regularly.

Encrypt your database data! The backups are not encrypted to allow quick restore.

Credits

Initially this was a fork of rds-postgres-backup-s3-secure by Emanuel Jöbstl.

About

Scheduled PostgreSQL backups to AWS S3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published