Backup PostgreSQL to AWS S3
Introduction
Backup PostgreSQL to AWS S3 step by step
Install awscli
Install AWS CLI:
pip install awscli
Configure your credentials:
aws configure
Clone backup tool
Clone bash tool:
git clone https://github.com/gabfl/pg_dump-to-s3.git
# Alternatively, download https://github.com/gabfl/pg_dump-to-s3/archive/refs/heads/main.zip
Edit configuration:
cd pg_dump-to-s3/
nano .conf
Additionally, if your database requires a password for authentication, you will need to create a ~/.pgpass
file see documentation.
Run the backup
./pg_dump-to-s3.sh
# * Backup in progress.,.
# -> backing up test...
# upload: ../../../tmp/2023-06-28-at-22-20-08_test.dump to s3://*****/backups/2023-06-28-at-22-20-08_test.dump
# ...database test has been backed up
# * Deleting old backups...
# ...done!