pg_dump-to-s3 icon indicating copy to clipboard operation
pg_dump-to-s3 copied to clipboard

Automatically dump and archive PostgreSQL backups to Amazon S3

pg_dump-to-s3

Automatically dump and archive PostgreSQL backups to Amazon S3.

Requirements

Setup

  • Use aws configure to store your AWS credentials in ~/.aws (read documentation)
  • Rename pg_dump-to-s3.conf.sample to pg_dump-to-s3.conf and set your PostgreSQL's credentials and the list of databases to back up
  • If your PostgreSQL connection uses a password, you will need to store it in ~/.pgpass (read documentation)

Usage

./pg_to_s3.sh

#  * Backup in progress.,.
#    -> backing up my_database_1...
#       ...database my_database_1 has been backed up
#    -> backing up my_database_2...
#       ...database my_database_2 has been backed up
#  * Deleting old backups...
#    -> Deleting 2018-05-24-at-03-10-01_my_database_1.dump
#    -> Deleting 2018-05-24-at-03-10-01_my_database_2.dump
#
# ...done!

Restore a backup

pg_restore -d DB_NAME -Fc --clean PATH_TO_YOUR_DB_DUMP_FILE