How to Configure CockroachDB Backup User

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a cockroachdb backup user by creating a role with specific backup privileges. Then you grant that role access to target databases or tables. Many teams take a shortcut and use the root admin role for backup jobs. This practice creates a major risk if a script or key leaks. An attacker with that admin key can drop tables or steal all data. A dedicated role limits what the backup job can do inside your cluster. How to set up a cockroachdb backup user CockroachDB uses a role-based mod

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 cockroachdb backup user by creating a role with specific backup privileges. Then you grant that role access to target databases or tables. Many teams take a shortcut and use the root admin role for backup jobs. This practice creates a major risk if a script or key leaks. An attacker with that admin key can drop tables or steal all data. A dedicated role limits what the backup job can do inside your cluster.

How to set up a cockroachdb backup user

CockroachDB uses a role-based model to control who can run backups. In older setups, only cluster admins could run full cluster or database backups. Now, admins can delegate backup tasks to dedicated roles without giving away full control. You start by creating a standard login user in the database. Next, you assign system or database backup privileges to that specific user.

The exact privileges depend on the scope of the backup job. A full cluster backup requires a system-level privilege granted by an existing admin. A database or table backup only needs backup rights on those specific objects. The backup role also needs read access to the source data it copies. If the user runs restore jobs later, it needs restore privileges too.

Storage credentials also play a big part in this workflow. The database nodes must write backup files to cloud storage buckets. Teams can pass cloud storage keys in the backup command or use node identities. Using implicit node roles keeps cloud keys out of database scripts and logs.

What native backup roles solve and what they miss

Native backup roles solve the problem of overly broad admin access for automated scripts. A dedicated cockroachdb backup user cannot delete tables or change cluster settings. It can only read data and send backup files to external storage. This setup separates day-to-day maintenance from full system administration.

Still, native database roles only check who logs in at the start. They do not inspect what individual statements or commands do in flight. A user with backup rights often holds broad read access across many tables. If an engineer uses that shared backup login, they can query sensitive rows directly.

User Provisioning (SCIM) + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Native roles also leave gaps in audit logs and data privacy. When five engineers share one backup role, the database log shows one name. You cannot tell which person ran an ad-hoc backup or read a table. Also, native roles cannot rewrite sensitive fields like emails or card numbers in results. Anyone using that account sees raw data in query outputs.

Managing credentials and storage access for backups

Automated cron jobs and CI pipelines need a way to log in safely. Many teams store passwords or client certificates in central secret stores. The backup runner fetches the key, connects to the cluster, and starts the job. When the job finishes, the runner closes the session.

Long-lived passwords for a cockroachdb backup user still create ongoing work for security teams. Someone must rotate those keys on a regular schedule and update every script. If an engineer leaves the team, shared keys require an immediate reset everywhere. Short-lived credentials and strict command checks reduce this manual work and lower risk.

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

Does a cockroachdb backup user need full admin rights?

No, a backup user does not need full admin rights in modern releases. You can grant specific backup privileges at the system, database, or table level.

Can the same role run both backups and restores?

Not by default, because backup and restore privileges are separate in the database. You must grant restore rights to the role before it can load data back.

How should a backup user authenticate to the cluster?

Automated backup jobs should use client certificates or short-lived tokens instead of static passwords. This approach prevents plain-text passwords from sitting in script files.

The query runs. The emails stay hidden.