> Full Neon documentation index: https://neon.com/docs/llms.txt

# How do I create and download a backup of my Neon database to my local machine?

Run pg_dump in custom format against a direct connection string and save the archive to disk.

Use `pg_dump` against a direct (non-pooled) Neon connection string. The custom format (`-Fc`) gives you a single compressed archive that `pg_restore` can read selectively and in parallel. The archive is saved on your machine, so you have a copy that doesn't depend on Neon. See [Backups with pg_dump](https://neon.com/docs/manage/backup-pg-dump) for the full reference.

## Create the backup

Click **Connect** in the Neon Console nav and turn **Connection pooling** off to get the **direct** connection string (no `-pooler` in the hostname). Then run:

```bash
pg_dump -Fc -v -d "postgresql://alex:AbC123dEf@ep-cool-darkness-a1b2c3d4.us-east-2.aws.neon.tech/neondb?sslmode=require&channel_binding=require" -f neondb-backup.dump
```

- `-Fc` writes a custom-format archive that `pg_restore` can read.
- `-v` prints progress as it dumps.
- `-d` is the source connection string.
- `-f` is the output file.

For a date-stamped file name, use command substitution:

```bash
pg_dump -Fc -d "$NEON_URL" -f "neondb-$(date +%Y-%m-%d).dump"
```

### Restore the backup later

`pg_restore` reads custom-format archives back into any Postgres database:

```bash
pg_restore -v -d "$TARGET_URL" neondb-backup.dump
```

Add `--no-owner` if you're restoring to a different role, and `--clean --if-exists` if you want to drop existing objects first.

## When to use a local backup

Lakebase Postgres keeps a change history that supports [instant restore](https://neon.com/docs/postgres/backup-restore/branch-restore) (point-in-time restore) of root branches within your project's [history window](https://neon.com/docs/postgres/backup-restore/history-window): up to 6 hours on the Free plan, up to 7 days on the Launch plan, and up to 30 days on the Scale plan. For most accidental deletes, instant restore is faster than restoring from a local file.

A local `pg_dump` backup covers cases that instant restore doesn't:

- A copy outside Neon, in case you lose access to your Neon organization or delete the project
- Long-term archival beyond your history window
- Compliance requirements that mandate an external copy
- Moving data into a different Postgres instance

**Warning: Use a direct connection for pg_dump**

`pg_dump` relies on session-level `SET` statements, which Neon's PgBouncer doesn't support in transaction mode, so a dump over a pooled connection fails with errors. Connect through the direct hostname (no `-pooler` segment).

**Tip: For large databases**

`pg_dump` can dump tables in parallel with `-j <njobs>`, but only in directory format (`-Fd`), which writes a folder instead of a single file. `pg_restore -j <njobs>` runs a parallel restore from either a custom or directory archive. Set `<njobs>` to the number of available CPUs. Neon also recommends `-Z 1` for compression, since higher levels slow the dump. See [Advanced pg_dump and pg_restore options](https://neon.com/docs/import/migrate-from-postgres#advanced-pg_dump-and-pg_restore-options) and the [pg_dump reference](https://www.postgresql.org/docs/current/app-pgdump.html).

> **See all pg_dump options**
>
> Parallel dumps, ownership handling, large objects, and piping pg_dump to pg_restore for small databases.
>
> [Read the migration guide](https://neon.com/docs/import/migrate-from-postgres)

---

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": "/faqs/download-database-backup-locally"}` to https://feedback.neon.tech/ (no auth required).
