The point-in-time path was rehearsed on the production project on 2026-11-17, and the times below
are from that drill. Restoring from the daily export is not yet rehearsed.
apiKeys Firestore collection, so a raw key can never be read back or reissued from the hash. If the collection is lost or corrupted, every self-serve key stops working at once and the only way back is a backup. Static keys in API_KEYS are not in Firestore and keep working (Firestore outage has the full blast radius).
The API reads the database named by FIRESTORE_DATABASE_ID in the project named by FIRESTORE_PROJECT_ID. Unset means (default). An invalid id refuses the boot, so a typo leaves the previous revision serving, and each revision logs Firestore database: <id> at boot. A restore is always made into a new, separately named database and checked from a staging service before production is pointed at it.
Recovery objective
The 2026-11-17 time includes one failed staging boot, from before the staging command below passed the mainnet endpoints.
Backup configuration
Run once per project, and again after any project move. Placeholders:<project>, <location> (the location of the (default) database, from gcloud firestore databases describe --database='(default)' --format='value(locationId)'), <export bucket> and <export account> (a service account used only by the scheduled export).
-
Turn on point-in-time recovery (seven days of versions, readable by the minute):
Expected:
POINT_IN_TIME_RECOVERY_ENABLEDand604800s. The oldest readable minute isearliestVersionTime, from the samedescribewith--format='value(earliestVersionTime)'; on 2026-11-17 it was seven days back. -
Create the export bucket, private and in the same project, so only the project’s own Firestore service agent writes to it:
On gcloud 586.0.0 (2026-11-17), both
gcloud storage bucketscommands crashed withmodule 'ssl' has no attribute 'PROTOCOL_TLSv1'. The same bucket withgsutil:Grant nobody else access to the bucket. Expected fromgcloud storage buckets describe gs://<export bucket>:public_access_prevention: enforced,uniform_bucket_level_access: true, and the 30 day delete rule. -
Schedule the daily export of the
apiKeyscollection:Run it once by hand withgcloud scheduler jobs run firestore-export-api-keys --location=<location>. Expected after a minute:gcloud storage ls gs://<export bucket>lists a folder named by the export’s start time. -
Confirm audit logging for Firestore: in the project’s audit log settings, the Cloud Firestore API has Data Write (and Admin Read) on. Expected from
gcloud projects get-iam-policy <project> --format=json | jq '.auditConfigs': an entry fordatastore.googleapis.comlistingDATA_WRITE.
Service account permissions
The API’s runtime service account holds only what the API needs:
No other project role. The
service-account check of the migration check fails when the runtime account holds any other project role.
Restore
Pick a new database id for the restore, such askeys-restore-<yyyymmdd>: 4 to 63 lowercase letters, digits or hyphens, starting with a letter. Never restore over (default). Start a timer: the elapsed time until a key resolves is the recovery time to record.
From point-in-time recovery
Use this when the loss happened in the last seven days. Pick the last whole minute before the loss, in UTC:From the daily export
Use this when the loss is older than seven days or point-in-time recovery is unavailable. Pick the newest export folder from before the loss:SUCCESSFUL. Only apiKeys is in the export, so usage and the counter start empty in this database.
Point a staging service at it
A separate service, so production’s configuration and traffic are not touched. Use the image production serves now and the same runtime service account. A production boot refuses to start without explicit mainnet endpoints (STELLAR_RPC_MAINNET is not set ... A production boot requires an explicit mainnet endpoint.), so the staging service gets production’s STELLAR_RPC_MAINNET and PATH_ROUTING_API_MAINNET. They go through a file, not --set-env-vars, because STELLAR_RPC_MAINNET can be a comma-separated list. Their URLs can carry provider keys: create the file readable only by you, never paste its contents anywhere, and delete it after the deploy:
grep prints 2 (if it prints less, production binds the endpoint from a secret: pass it with --set-secrets instead), and the deploy ends with the service ready.
The proof that staging reads the restore, not production’s database, is a pair of testnet test keys, never an integrator’s: $KEY_BEFORE created before the restore point and $KEY_AFTER created after it. In a second terminal:
{"error":{"code":"invalid_source",...}} for the key from before, which the API only answers once the key has resolved, and 401 for the key from after, which still resolves on production. The boot log line is Firestore database: <restore id>; the API writes it as JSON, so the filter reads jsonPayload.message, not textPayload. Stop the timer and record the elapsed time and the date in the recovery objective.
Point production at it
Only after the staging check passes, during a real loss:<restore id>, and a self-serve key resolves against $API.
Clean up after a drill
The clone inherits delete protection from(default), so a delete alone fails with FAILED_PRECONDITION ... DELETE_PROTECTION_ENABLED. Turn it off on the restore database only, then delete:
Migration check
scripts/migration-check.sh is the required step after any project or organization move, and after any IAM, policy or service change. It is read-only: it only describes, lists and reads (gcloud describe, list and get-iam-policy, gh run list, gh api GET, curl GET). It prints PASS, FAIL or SKIPPED per check and exits non-zero on any failure.
Install the beta component once with
gcloud components install beta (the domain check needs it; the script disables prompts, so a missing component fails that check and names the command). Then run it signed in to the project, after a manual run of the deploy workflow:
11 passed, 0 failed, 0 skipped. A check whose input is unset is SKIPPED. The header of the script lists every input and its default, and how to add a check. To prove the gate fails, run it with DRILL=fail-check: ingress-invoker expects a wrong member, fails, and the run exits 1.
The Migration check workflow runs the same script by hand from GitHub Actions, as the deploy identity. Checks that identity is not allowed to read are reported as SKIPPED; run the script as an operator for the full list.