# Automate pg_dump backups

Keeping regular backups of your database is critical for protecting against data loss. While Neon offers an [instant restore](/guides/postgres-backup-restore-branch-restore) feature (point-in-time restore) for backups of up to 30 days, there are scenarios (such as business continuity, disaster recovery, or regulatory compliance) where maintaining independent and longer-lived backup files may be necessary. In these cases, using the Postgres `pg_dump` tool to create backups and storing them on a reliable external service (like an AWS S3 bucket) gives you control over long-term retention and recovery of your data.

Manually performing backups can be tedious and time consuming, so automation is key to ensure you're taking backups consistently. An automated backup process also lets you enforce retention policies by automatically cleaning up old backups, saving storage, and keeping your backup repository tidy.

This two-part guide walks you through setting up an automated backup pipeline using `pg_dump` and GitHub Actions. You will configure everything needed to run nightly backups and store them in S3, ensuring your data is available to restore if needed.

:::callout{intent="note"}
Avoid using `pg_dump` over a [pooled connection string](/guides/postgres-reference-glossary#pooled-connection-string). Use an [unpooled connection string](/guides/postgres-reference-glossary#unpooled-connection-string) (the hostname without the `-pooler` suffix) for the backup connection.
:::

::::card-grid
:::card{title="Part 1: Create an S3 bucket to store backups" href="/guides/postgres-manage-backups-aws-s3-backup-part-1"}
Set up an AWS S3 bucket for storing backups
:::

:::card{title="Part 2: Automate with GitHub Actions" href="/guides/postgres-manage-backups-aws-s3-backup-part-2"}
Schedule nightly backups with GitHub Actions and pg\_dump
:::
::::

## Related pages

- [Backups](./postgres-backup-restore-backups.md)
- [Instant restore](./postgres-backup-restore-branch-restore.md)
- [Time Travel](./postgres-backup-restore-time-travel-assist.md)
- [History window](./postgres-backup-restore-history-window.md)
- [Backups with pg_dump](./postgres-manage-backup-pg-dump.md)
- [Create an S3 bucket to store Postgres backups](./postgres-manage-backups-aws-s3-backup-part-1.md)
- [Set up a GitHub Action to perform nightly Postgres backups](./postgres-manage-backups-aws-s3-backup-part-2.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
