{"id":26694360,"url":"https://github.com/mattf96s/fly-pg-backup-example","last_synced_at":"2026-05-17T17:08:34.108Z","repository":{"id":181634843,"uuid":"584334585","full_name":"mattf96s/fly-pg-backup-example","owner":"mattf96s","description":"Using GitHub actions to automate Fly.io Postgres backups to S3","archived":false,"fork":false,"pushed_at":"2023-02-23T08:51:09.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-22T22:20:31.436Z","etag":null,"topics":["backup-database","flyio","postgres"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattf96s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-01-02T09:13:41.000Z","updated_at":"2023-09-06T19:36:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"a5a05e1e-2ab7-43b5-a264-87bcde2e1e9c","html_url":"https://github.com/mattf96s/fly-pg-backup-example","commit_stats":null,"previous_names":["mattf96s/fly-pg-backup-example"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/mattf96s/fly-pg-backup-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattf96s%2Ffly-pg-backup-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattf96s%2Ffly-pg-backup-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattf96s%2Ffly-pg-backup-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattf96s%2Ffly-pg-backup-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattf96s","download_url":"https://codeload.github.com/mattf96s/fly-pg-backup-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattf96s%2Ffly-pg-backup-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33147340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup-database","flyio","postgres"],"created_at":"2025-03-26T18:29:11.235Z","updated_at":"2026-05-17T17:08:34.090Z","avatar_url":"https://github.com/mattf96s.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Automated Fly.io Postgres Database Backups\n\nAn example showing how to use a GitHub action to automate backups of a Fly.io Postgres database as well as then uploading the backups to S3 (or another storage provider of your choosing).\n\n## Quick Start\n\nClone this repo and add your environment variables as secrets to your GitHub action.\n\n- Control the cron frequency in the backup.yml file\n  \u003c/br\u003e\n\n## Recognition\n\nThis example is based on the following [tutorial](https://www.advantch.com/blog/automate-postgres-database-backups-on-fly-dot-io/) by \u003ci\u003eadvantch\u003c/i\u003e. However, there were certain steps which were unclear to me—as someone with relatively little python or bash knowledge.\n\nI also find the Fly naming conventions confusing—particularly between the switching of hyphens and underscores in app names. This made the tutorial harder to follow and I thought it was worth sharing for others.\n\u003c/br\u003e\n\n## A Simple Explanation\n\nWe proxy our Postgres app to port 5432 and then perform usual pg_dump commands.\n\n## Setting up your environment variables\n\nAdd the following environment variables to your GitHub action secrets.\n\nFor illustration purposes, assume my main fly app is called `my-example-app` and my attached Postgres fly app is called `my-example-app-db`.\n\n\u003c/br\u003e\n\n\u003e 💡 How to find some of these values is explained further down.\n\n\u003c/br\u003e\n\u003ci\u003eFly.io specific variables\u003c/i\u003e\n\n|                | Example           | Explanation                    |\n| -------------- | ----------------- | ------------------------------ |\n| PG_PASSWORD    |                   |                                |\n| PG_USER        | my_example_app    | Note the underscores           |\n| PG_DATABASE    | my_example_app    | Note the underscores           |\n| APP_NAME       | my-example-app    | main fly app name              |\n| PROXY_APP_NAME | my-example-app-db | attached fly Postgres app name |\n\n\u003c/br\u003e\n\u003ci\u003eS3 specific variables\u003c/i\u003e\n\n|                      | Example             | Explanation |\n| -------------------- | ------------------- | ----------- |\n| S3_ACCESS_KEY        |                     |             |\n| S3_SECRET_ACCESS_KEY |                     |             |\n| S3_BUCKET            | my-database-backups |             |\n| AWS_REGION           | eu-west-1           |             |\n\n\u003c/br\u003e\n\n\u003ci\u003eSlack specific variables\u003c/i\u003e\n\u003c/br\u003e\n\n\u003e For alerting a channel if the workflow fails. See [here](https://github.com/marketplace/actions/slack-send) for more info.\n\n|                  | Example | Explanation |\n| ---------------- | ------- | ----------- |\n| SLACK_CHANNEL_ID |         |             |\n| SLACK_BOT_TOKEN  |         |             |\n\n\u003c/br\u003e\n### How to retrieve certain environment values\n\n\u003e Ensure that you are logged into your fly account:\n\n```\nflyctl auth login\n```\n\n### Retrieving Your App Names\n\n```\nflyctl list apps\n```\n\n### Retrieving your Postgres Users\n\n```\nfly postgres users list -a my-example-app-db\n```\n\n### Retrieving the Postgres specific values\n\nFor your app name, do not use the Postgres app name; instead, it needs to be the app to which the PostGres app is attached. If you omit the -a flag it will use the app specified in your fly.toml file—which is usually what we want anyway.\n\n```\nflyctl ssh console -a my-example-app\n```\n\n```\necho $DATABASE_URL\n```\n\nYou can also see all variables with\n\n```\nprintenv\n```\n\nAgain, assuming my main fly app is called `my-example-app` and my postgres fly app is called `my-example-app-db`.\n\nYour `DATABASE_URL` should look something like: `postgres://my_example_app:Rhakkai12jsjs@top2.nearest.of.my-example-app-db.internal:5432/my_example_app?sslmode=disable`\n\n\u003e 💡 postgres://{username}:{password}@{hostname}:{port}/{database}?options\n\n[Learn more here](https://fly.io/docs/postgres/connecting/connecting-internal/)\n\nWhat is confusing is when to use hyphens and when to use underscores.\n\nIt helps to remember that \"Fly Postgres is a regular app\". So we need to differentiate between the naming of the Fly app hosting the Postgres database to that of the actual database itself.\n\n## For Local Testing:\n\nEnsure Postgres is setup correctly (especially the path)\n\n```\nsudo mkdir -p /etc/paths.d \u0026\u0026 echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp\n```\n\nCreate and activate a virtual environment.\n\nRun the following lines of code in your terminal:\n\n```\n$ python3 -m venv .venv\n$ source .venv/bin/activate\n$ python3 -m pip install -r requirements.txt\n```\n\nThe connection to DB often hangs when testing locally--so you may need to [kill it](https://stackoverflow.com/questions/20091433/cant-find-out-where-does-a-node-js-app-running-and-cant-kill-it).\n\n```\nlsof -i tcp:5432\nkill xxx\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattf96s%2Ffly-pg-backup-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattf96s%2Ffly-pg-backup-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattf96s%2Ffly-pg-backup-example/lists"}