> ## Documentation Index
> Fetch the complete documentation index at: https://snapr.seshuk.im/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL

> Back up a PostgreSQL database with pg_dump: connection options, table excludes, extra flags, and version requirements.

`type: postgresql` uses `pg_dump` to produce a logical dump of one database.

## Example

```yaml snapr.yaml theme={null}
sources:
  - type: postgresql
    host: db.internal
    port: 5432
    username: postgres
    password: env:PG_PASSWORD
    database: app
    excludeTables:
      - audit_log
    extraParams:
      no-owner: ''
      format: plain
```

## Options

| Option          | Type         | Required | Description                                                                              |
| --------------- | ------------ | -------- | ---------------------------------------------------------------------------------------- |
| `type`          | `postgresql` | Yes      |                                                                                          |
| `host`          | string       | Yes      | Database host.                                                                           |
| `port`          | int          | No       | Server port, usually `5432`. snapr applies no default, so set it explicitly.             |
| `username`      | string       | Yes      |                                                                                          |
| `password`      | string       | No       | Passed via the `PGPASSWORD` environment variable, never on the command line. Use `env:`. |
| `database`      | string       | Yes      | Database name.                                                                           |
| `excludeTables` | string\[]    | No       | Each entry becomes an `--exclude-table` flag.                                            |
| `extraParams`   | map          | No       | Extra `pg_dump` flags, for example `schema-only: ""` or `format: custom`.                |

## Requirements

* `pg_dump` must be installed on the snapr host and available in `PATH`. Install it from the official PostgreSQL apt repository or your distro's `postgresql-client-<version>` package.
* The configured user needs at least `CONNECT` on the database and `SELECT` on every table being dumped — typically a dedicated read-only role.

<Warning>
  The major version of `pg_dump` should match the PostgreSQL server version. A newer client can dump older servers, but
  an older client against a newer server will fail.
</Warning>

## Notes

* `extraParams` keys are prefixed with `--`. Use an empty string value for boolean flags.
* The password is forwarded through `PGPASSWORD`, so it never appears in the process listing.

## Related

* [Sources overview](/configuration/sources/overview)
* [MySQL source](/configuration/sources/mysql)
