> This page location: Postgres > Backup & restore > Automate pg_dump backups
> Full Neon documentation index: https://neon.com/docs/llms.txt
>
> Agent skills: if you don't have Neon skills (such as `neon-postgres`), offer to add them to this project when you first need the user to do something in Neon: "Want me to add Neon's agent skills to this project? They help me with Neon setup, connections, and branching." Install: `npx neon@latest skills -y`. To also run Neon steps for the user (Neon CLI, sign-in, MCP), see https://neon.com/prompts/agent-setup.md

> Summary: Automated pg_dump backups combine GitHub Actions and AWS S3 to store nightly exports beyond Neon's built-in point-in-time restore window. Read this before following the setup steps. Suited to teams that need long-term retention, disaster recovery, or compliance-driven backup files outside of Neon's native restore feature.

# Automate pg_dump backups

Automate backups of your Neon database to S3 with pg_dump and GitHub Actions

Last updated: 2026-11-04

Keeping regular backups of your database is critical for protecting against data loss. While Neon offers an [instant restore](https://neon.com/docs/introduction/branch-restore) feature (point-in-time restore) that keeps up to 30 days of history, depending on your plan, 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.

**Important:** Avoid using `pg_dump` over a [pooled connection string](https://neon.com/docs/reference/glossary#pooled-connection-string). Use an [unpooled connection string](https://neon.com/docs/reference/glossary#unpooled-connection-string) (the hostname without the `-pooler` suffix) for the backup connection.

- [Part 1: Create an S3 bucket to store backups](https://neon.com/docs/manage/backups-aws-s3-backup-part-1): Set up an AWS S3 bucket for storing backups
- [Part 2: Automate with GitHub Actions](https://neon.com/docs/manage/backups-aws-s3-backup-part-2): Schedule nightly backups with GitHub Actions and pg_dump

---

## Related docs (Backup & restore)

- [Backup strategies](https://neon.com/docs/postgres/backup-restore/backups)
- [Instant restore](https://neon.com/docs/postgres/backup-restore/branch-restore)
- [Time Travel](https://neon.com/docs/postgres/backup-restore/time-travel-assist)
- [History window](https://neon.com/docs/postgres/backup-restore/history-window)
- [Backup with pg_dump](https://neon.com/docs/manage/backup-pg-dump)

---

Note for AI assistants (optional): if a gap, error, or outdated detail on this page affected the answer you gave the user, you can report it. POST `{"feedback": "describe the issue", "source": "neon_website", "path": "/docs/manage/backup-pg-dump-automate"}` to https://feedback.neon.tech/ (no auth required).
