A simple AWS Lambda function that runs pg_dump and streams the output to s3.
Using AWS, you can schedule it to run periodically.
- Create an AWS lambda function using the zip as "function package".
- Add a "CloudWatch Events - Schedule" trigger.
- In the 'rule', setup your schedule and configure the lamba input to something like:
{
"PGHOST": "database.myserver.com",
"PGUSER": "my-user",
"PGPASSWORD": "my-password",
"PGDATABASE": "my-database-name",
"S3_BUCKET": "my-s3-backup-bucket",
"SUBKEY": "production"
}This function will store your backup with the following s3 key:
s3://${S3_BUCKET}/${SUBKEY}/YYYY-MM-DD/YYYY-MM-DD@HH-mm-ss.backup