How to Configure Firestore Backup User

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up a firestore backup user, create a Google Cloud service account. Assign this account export roles for the database and write roles for cloud storage. Many teams take shortcuts and assign broad project editor roles to backup scripts. Broad roles create huge security risks if an attacker steals that service account key. A compromised broad role lets an intruder alter live collections or delete whole buckets. How a firestore backup user works in Google Cloud A dedicated firestore backup

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.

To set up a firestore backup user, create a Google Cloud service account. Assign this account export roles for the database and write roles for cloud storage. Many teams take shortcuts and assign broad project editor roles to backup scripts. Broad roles create huge security risks if an attacker steals that service account key. A compromised broad role lets an intruder alter live collections or delete whole buckets.

How a firestore backup user works in Google Cloud

A dedicated firestore backup user runs as a machine identity inside your cloud project. This identity does not need interactive login rights or console views for daily tasks. Instead, automated schedulers use this account to trigger export jobs on a fixed timer. The export job reads document data and writes backup files to a storage bucket.

Good architecture separates the role that starts exports from the role that reads data. The backup identity only needs permission to start an export operation in the database. It also needs permission to write new objects into one specific cloud storage bucket. It should not have permission to overwrite or delete old backups in that bucket. This setup stops a bad script from wiping out past recovery points during a failure.

How to scope storage and database roles

Teams should place backup buckets in a separate project from the live database project. This layout keeps backup files safe even if an admin breaks the main project. You grant the backup identity write permissions only on that target storage bucket. Next, you turn on object retention locks on the bucket to block early deletion.

For the database side, you build a custom role with only export permissions. Standard predefined roles often bundle import and export actions into the same role group. A dedicated backup job should never have the right to import data over live records. Splitting backup and restore identities keeps routine export tasks from overwriting live data by mistake. Teams should also use workload identity instead of downloadable keys whenever the platform allows it.

What native roles solve and where gaps remain

Native cloud roles do a great job of limiting what automated export jobs can do. They stop a backup script from reading unrelated buckets or changing live database records. Cloud audit logs also record every time the service account starts an export job. This gives security teams a clear record of when scheduled backups run.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, static roles only check who logs in to start a job or session. They do not inspect individual queries when engineers run manual data checks before a restore. When an engineer troubleshoots a broken backup, they often query live collections to compare records. Native roles cannot rewrite sensitive fields like emails, phone numbers, or card numbers in flight. Once a user has read permissions, every query returns raw data to their local screen.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits inline in the protocol beside the service as an open-source proxy, a sidecar for your database or API. On every production query an agent or human runs, hoop.dev decides whether to pass, mask, block, or escalate it for review.

Before a query runs, hoop.dev guardrails check the statement against your rules, an AI Analyzer you configure can score intent or hold risky calls for human approval, and hoop.dev data masking rewrites sensitive fields in responses in memory. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Does a firestore backup user need read permissions on all documents?

No, the account only needs permission to start a managed export job in the project. The managed export service handles the underlying document reads and writes files to cloud storage.

Should the same service account run both backups and restores?

No, you should keep backup and restore permissions in separate accounts at all times. A restore account needs import permissions that can overwrite live database collections during a mistake.

How can teams protect sensitive data during manual backup checks?

Teams should avoid giving engineers raw read roles on production databases or backup files. Instead, use dynamic data masking to rewrite emails, phone numbers, and card numbers in query results.

Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.

The query runs. The emails stay hidden.