How to Configure Cloud SQL Backup User
You set up a cloud sql backup user by creating a database role with login and read permissions on target schemas. You then grant select rights on current and future tables so export jobs read data without admin rights. Many teams take a shortcut and use the default admin account for backups. That choice exposes every table and allows accidental data changes during routine export jobs. How to set up a cloud sql backup user Cloud SQL for PostgreSQL is a managed database service. Customers canno
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 set up a cloud sql backup user by creating a database role with login and read permissions on target schemas. You then grant select rights on current and future tables so export jobs read data without admin rights. Many teams take a shortcut and use the default admin account for backups. That choice exposes every table and allows accidental data changes during routine export jobs.
How to set up a cloud sql backup user
Cloud SQL for PostgreSQL is a managed database service. Customers cannot create or use accounts with true superuser attributes. Google reserves a system account named cloudsqladmin for full superuser control. Customers cannot alter or delete these system roles. Instead, the service gives you the cloudsqlsuperuser role for daily admin work.
The default postgres admin account belongs to this cloudsqlsuperuser group. It starts without a password, so you must set one before you log in. This default role can create roles, create databases, and log in. It does not hold superuser or replication attributes, though cloudsqlsuperuser can create replication users.
You should not use the default postgres account for routine logical backups. Instead, log in with an admin account and create a dedicated backup role. Give this new role login rights and connect permissions on the target database. Next, grant usage on each schema that your export job needs to read.
Finally, grant select permissions on all existing tables and views in those schemas. You also need to alter default privileges for the schemas. This step ensures the backup role can read new tables that teams create later. If your export tool uses logical replication slots, a cloudsqlsuperuser can grant replication rights to the role.
What native database roles solve and what they leave open
A scoped backup role solves the basic problem of over-privileged automation. If an attacker steals the backup key, they cannot drop tables or alter schemas. The database engine blocks any write commands from that account right away. This setup keeps your export scripts from breaking production data by mistake.
Still, native database roles only check who logs in and which tables they can read. Once the backup role has select rights on a table, it reads every column and row by default. The database role cannot tell the difference between a scheduled export and a developer running manual queries. Anyone who holds those credentials can pull full tables of customer data.
User Provisioning (SCIM) + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
This gap matters when tables hold sensitive fields like emails, phone numbers, card numbers, or national IDs. A native role cannot mask those fields in flight for lower-tier test exports. It also cannot ask for peer approval before someone runs a manual dump. Teams must manage static passwords or keys across every script and runner on their own.
Why shared backup credentials create audit blind spots
Engineering teams often reuse the same backup user for staging refreshes and local testing. Developers grab the backup credentials to pull a snapshot of production data onto their laptops. When three people and two scripts share one database role, your audit logs lose value. You can see that the backup user read the customer table at midnight.
You cannot see which engineer ran the export or why they needed it. Rotating that shared password becomes risky because changing it breaks automated jobs. Teams delay password rotation for months to avoid breaking nightly builds. A better approach ties every database session to an individual identity and inspects queries in flight.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev sits inline in the protocol beside each supported service as an open-source proxy, a sidecar for your database or API. For every query or command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human approval.
First, hoop.dev guardrails block banned queries before they run or hold risky ones for review, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Can a cloud sql backup user have full superuser rights?
No, Cloud SQL is a managed service and does not give customers true superuser accounts. Only the Google system account holds superuser rights, while customers use cloudsqlsuperuser or scoped read roles.
Should I use the default postgres user for automated backups?
No, the default postgres user belongs to cloudsqlsuperuser and can create databases and roles. You should create a separate role with only read permissions on the schemas you want to export.
How do I let a backup user read tables created in the future?
You must update the default privileges on each target schema in your database. This rule grants select permissions on new tables to your backup role as soon as they appear.
Related guides
In this post