Share this page: Follow me to be notified of new articles:

pg_dump-to-s3: Easy way to backup PostgreSQL databases to Amazon S3

Introduction

pg_dump-to-s3 allows to dump a list of PostgreSQL databases and store them on AWS S3. It's designed for small to medium databases requiring basic backups.

It takes advantage of several S3 features:
  1. Auto expiration of files to rotate over 1 week of backups
  2. Use of Amazon S3 Infrequent Access storage class to benefit from good performances for 50% of the cost of S3 Standard

Try it yourself

You can try all the methods yourself after downloading the source code below.

Source code

You can find the source code on Github:
Watch Star Fork Download

Basic usage

./pg_to_s3.sh database1 database2 database3 [...]

Credentials

AWS credentials

AWS credentials should be stored in a file called "~/.aws".
Look at the "Quick Configuration" documentation on AWS.

PostgreSQL password

If you use a password on your PostgreSQL database it's recommended to store it in a ".pgpass" file.
Last update of this page: March 27, 2017
Please do not copy any of the content of this website without asking me first.