Skip to content

Daily

Export Firestore to Cloud Storage nightly

Your Firestore data is exported to a dated folder each night, and you are told if an export fails.

Runs
Daily
Apps
Firebase
AI
Not needed
Access
datastore scope; service account with Cloud Datastore Import Export Admin plus Storage write on the bucket

Send this to your assistant

Create a ClickRuntime automation: every night at 2am, export my whole Firestore database to gs://acme-firestore-backups in a folder named by date, wait for it to finish, and email me only if it fails.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A Firestore database holds the real state of an app: customers, orders, settings. A bad deploy, a script that deletes the wrong collection or a developer error in a migration can wipe data in seconds, and Firestore has no undo. Teams often plan to set up exports later, but the first time they need one is the moment they discover there is none. Rebuilding from scratch is not realistic for a live product. Few teams can afford that.

Every night, ClickRuntime starts a Firestore export into a dated folder in Cloud Storage, then polls the long-running operation Google returns until it finishes. It emails you if the export failed, or a short confirmation line if it succeeded.

Startups and small engineering teams without a dedicated operations person benefit most from this routine.

What you get out of it

  • Recover from accidental deletion

    A dated export in Cloud Storage gives you a known-good copy to restore from. A mistaken delete becomes an annoying hour rather than a lost customer base. It limits the damage of a mistake to a single day's changes. A silent failure is the worst kind of backup problem.

  • Find out about failures the same night

    Exports can fail due to permissions or quota changes. An email on failure means you fix it the next morning rather than discovering weeks later that there have been no backups.

  • Keep a history of dated snapshots

    Each export goes into its own dated folder, so you can pick the point in time you want. That helps when a problem was introduced three days ago and went unnoticed. Written proof is more convincing than a verbal assurance in security reviews.

  • Meet customer and audit expectations

    Enterprise customers and auditors ask whether you back up data. Dated exports and a log of results give a clear, verifiable answer, rather than a promise. Reliability like that is hard to get from personal discipline alone.

  • Free engineers from remembering

    Manual exports depend on one person's memory. A nightly schedule makes backups a property of the system, not a habit that lapses during releases or holidays. It stays reliable through releases and holidays.

How it works

What happens, step by step

  1. Every night ClickRuntime starts an export of your Firestore data to a Cloud Storage folder named with the date.

  2. It waits for the export to finish.

  3. If it fails, you get an email with the error. Otherwise you get a short line confirming the backup.

Before it runs live

  • Connect Firebase

What you get

RunsDaily
Export Firestore to Cloud Storage nightlytoday, 9:00Succeeded
Email · Backup failedFirestore backup failed {'code': 7, 'message': 'The caller does not have permission'}

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Run it at a different time, more or less often, or only on weekdays
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Firebase steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
back_up_firestore_every_night.pyexample
import time
from datetime import date
from clickruntime import on_trigger, credentials, http, notify

PROJECT = "acme-prod"
API = "https://firestore.googleapis.com/v1"

@on_trigger
def run(event):
    headers = {"Authorization": f"Bearer {credentials.connection('google', 'work')}"}
    prefix = f"gs://acme-firestore-backups/{date.today()}"
    op = http.post(f"{API}/projects/{PROJECT}/databases/(default):exportDocuments", headers=headers,
                   json={"outputUriPrefix": prefix}).json()
    for _ in range(40):
        op = http.get(f"{API}/{op['name']}", headers=headers).json()
        if op.get("done"):
            break
        time.sleep(15)
    if not op.get("done") or "error" in op:
        notify.email_me("Firestore backup failed", str(op.get("error", "Export did not finish in time")))
        return {"ok": False}
    return {"ok": True, "prefix": prefix}

FAQ

Common questions

What does the export need in Google Cloud?
A Cloud Storage bucket for the output and a service account with permission to export Firestore data and write to that bucket. The credentials are stored as secrets and are used only to start the export.
How do I know the export finished correctly?
The flow polls the operation Google returns until it reports done, and checks whether it ended in an error. A failure produces an email with the message, while a success produces one short confirmation line.
Does an export cost anything?
Firestore exports are billed as reads of the documents exported, plus Cloud Storage costs for the stored files. For small databases it is usually minor, but check your project's pricing, since large collections add up.
What permissions does it need?
datastore scope; service account with Cloud Datastore Import Export Admin plus Storage write on the bucket. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (daily). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Export Firestore to Cloud Storage nightly” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.