Learn how Neon compares to Aurora Serverless v2 - TL;DR: faster cold starts, responsive autoscaling, 80% lower costs
Docs/Platform/Backups

Backups

What you will learn:

  • About built-in backups with point-in-time restore

  • Creating backups using pg_dump

  • How to automate backups with GitHub Actions

Built-in backups with Neon's point-in-time restore feature

Neon retains a history for all branches, allowing you to restore your data to a particular date and time or Log Sequence Number (LSN). The history retention period is configurable. The supported limits are up to 24 hours for Neon Free Plan users, 7 days for Launch, 14 days for Scale, and 30 days for Business plan users. With this backup option, no action or automation is required. You can restore your data to a past state at any time by creating a database branch, which is a near-instant operation. This feature is referred to as Point-in-time restore.

For information about creating a point-in-time restore branch, see Branching — Point-in-time restore.

pg_dump

You can backup a database using pg_dump, in the same way backups are created for a standalone Postgres instance.

important

Avoid using pg_dump over a pooled Neon connection (see PgBouncer issues 452 & 976 for details). Use an unpooled connection instead.

This method dumps a single database in a single branch of your Neon project. If you need to create backups for multiple databases in multiple branches, you must perform a dump operation for each database in each branch separately.

To dump a database from your Neon project, please refer to the pg_dump instructions in our Migrate data from Postgres with pg_dump and pg_restore guide.

tip

When restoring a database dumped from Neon, you may encounter ALTER OWNER errors related to a cloud_admin role; for example:

pg_restore: error: could not execute query: ERROR: permission denied to change default privileges
Command was: ALTER DEFAULT PRIVILEGES FOR ROLE cloud_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO neon_superuser WITH GRANT OPTION;

This is a protected role in Neon that cannot be modified. To avoid this issue, you can add a -O or --no-owner option to your pg_restore command, as described Database object ownership consideration.

Automate Postgres Backups with a GitHub Action

These blog posts from Neon community members describe how you can schedule a backup to an Amazon S3 storage bucket using a GitHub Action:

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. Users on paid plans can open a support ticket from the console. For more details, see Getting Support.

Last updated on

Was this page helpful?