Data security and reliability are paramount for any application’s success.
Regular backups play a crucial role in ensuring that our data remains safe and accessible.
Fly.io’s postgres offers automated snapshots, but for added peace of mind, relying on
pg_dump for backups became essential.
GitHub Actions allows us to automate, customize, and execute software development workflows directly in our repositories.
In this blog post, we’ll explore how to automate the backup process of a Fly.io postgres database using GitHub Actions and saving them to a designated S3 bucket.
Fly Deploy Tokens:
Deploy tokens are used for secure authentication and authorization purposes during the deployment process. Before going further please read about Fly Deploy Tokens and create a deploy token.
S3 Bucket Creation Steps
As we are using S3 bucket to store the db backup files. Please follow the S3 Bucket Creation Steps to have S3 bucket with required credentials.
Within our GitHub repository, head to the
.github/workflows directory (if absent, create it),
and generate a new YAML file titled
Insert the following YAML content into our freshly crafted
Update all the values like
and S3 bucket
secret_key with the help of Github secrets.
The above Github action runs on every sunday. It takes the db backup and stores it on S3 bucket.