How to Configure Postgres Backup User
You configure a postgres backup user by creating a dedicated role with read grants on target schemas and tables. This setup allows automated dump jobs to read database objects while blocking data changes. Many engineering teams rush this setup by reusing. An app owner account or a superuser role for backups. When backup scripts run with broad write or admin rights. A compromised backup server can destroy production data. Even a strict read role still exposes every sensitive column in your datab
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You configure a postgres backup user by creating a dedicated role with read grants on target schemas and tables. This setup allows automated dump jobs to read database objects while blocking data changes.
Many engineering teams rush this setup by reusing. An app owner account or a superuser role for backups. When backup scripts run with broad write or admin rights. A compromised backup server can destroy production data. Even a strict read role still exposes every sensitive column in your database to the backup host.
How a postgres backup user works in native database roles
PostgreSQL manages grants through roles that can act as single login accounts or group roles. When you set up a postgres backup user, you create a login role that needs read access across your data objects at the core of a logical backup is the SELECT rights in PostgreSQL, the SELECT rights allows reading from any column or exact columns of a table view, or materialized view. This rights also enables the copy export task that backup. Utilities rely on to extract table rows.
To avoid granting grants one user at a time. Admins often configure a group role for read access. You grant schema usage and table read rights to the group role then assign the backup account as a member. You also need to account for the special PUBLIC role represents every role on the system by default, PUBLIC receives connection and temporary table rights on databases. Plus execution rights on functions and procedures in PostgreSQL 15 and later, the default config stops every user from creating new objects in the public schema if you run an earlier version or an upgraded database an admin must revoke that creation right from PUBLIC manually.
Managing new objects and default privileges for backups
A common failure in backup config happens. Developers add new tables to a database standard rights grants only apply to tables and views that exist at the moment you run the grant when a migration creates a new table tomorrow. The backup role might lack grants to read it. This gap causes scheduled backup jobs to fail mid-run or skip new tables.
Admins solve this by configuring default rights for future objects. Default rights attach to the exact role that creates the new tables. Such as a deployment role when that deployment role builds a new table the database applies the read rights to the backup role right away if multiple roles create tables across your system you must set default rights for each creating role.
User Provisioning (SCIM) + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native backup roles solve and what they leave open
Native database roles do a good job of separating read tasks from write tasks. A restricted backup role prevents an automated script from dropping tables. Altering schemas, or deleting rows by mistake. It also limits damage if an attacker steals the backup. Keys and tries to modify production records.
Still, native database grants only decide who can log in and which objects they can read once the backup role authenticates. It can pull permitted row (unless row-level security applies) of sensitive customer data in clear text. Native rights cannot inspect single queries in flight. Mask personal IDs during a developer dump. Require peer approval before a manual export runs if an engineer uses backup keys to pull a local copy for testing. Raw secrets and personal data leave the production boundary unchecked.
Check every Postgres query on the wire
Database roles and network rules decide who can open a session. They do not read what each SQL statement does after login. With hoop.dev, you run an open-source proxy, a sidecar for your Postgres, inline in the Postgres wire protocol. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review. Your apps and agents keep their login details and change only the host and port in the connection string their tool uses.
Before a query runs, hoop.dev guardrails refuse bad deletes or drops with a real Postgres error, or hold risky queries for approval. On the way back, hoop.dev data masking rewrites sensitive values in returned rows in memory, and every verdict goes to the audit trail. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for HIPAA, GDPR, and PCI DSS. See the code on GitHub.
Frequently asked questions
Why does a backup role need more than basic table SELECT rights?
Logical backups read table rows. Requires the SELECT rights to run queries and copy data out. The role also needs grants to look up schemas and read sequence values so the restored database functions properly.
Why did my backup fail after a recent schema migration?
PostgreSQL grants only cover existing tables. You configure default rights for future objects. Moreover, default rights only apply to objects created by the exact role you targeted in the default rule if a different developer account ran the migration. The backup user will not receive read rights on the new table.
Can a read-only backup user still create objects in the database?
In PostgreSQL 15 and newer, regular users cannot create objects in the default public schema out of the box in older versions, the system grants creation rights on the public schema to the PUBLIC role by default. Admins must revoke that right from PUBLIC and remove temporary table rights if they want strict read-only behavior.
Related guides
In this post