Restore a FlutterFlow Firestore database using one of four methods: full import from a Cloud Storage export (overwrites all data), point-in-time recovery from the Firebase Console (available on Firestore Native mode with PITR enabled, up to 7 days back), selective restore by importing to a temporary project and copying specific documents via Cloud Function, or document-level replay from an audit log. Always restore to a test project first to verify the backup before touching production.
Four restore methods for Firestore — choose based on what you lost and when
Restoring a Firestore database depends heavily on what type of backup you have and what you need to recover. A full Cloud Storage export restore is fast and complete but overwrites all existing data. Point-in-time recovery (Firestore PITR) is ideal when you can pinpoint exactly when a problem occurred — it creates a new database instance as it existed at that moment. Selective restore lets you recover specific collections or documents without touching the rest of the database, which is essential when only part of your data was corrupted or accidentally deleted. If you have an audit log, document-level replay lets you reconstruct specific records from their change history.
Prerequisites
- A Firebase project with Firestore (your FlutterFlow app's backend)
- An existing backup — either a Cloud Storage export, PITR enabled on your Firestore instance, or a custom JSON backup
- Access to Google Cloud Console and Firebase Console with Owner or Editor IAM permissions
- Understanding that full restores OVERWRITE existing data — there is no merge restore in Firestore
Step-by-step guide
Identify what you need to restore and choose the right method
Identify what you need to restore and choose the right method
Before attempting any restore, answer three questions: (1) What data is missing or corrupted? A specific collection, a specific document, or the entire database? (2) When did it last have correct data? Today? Last week? (3) What backup method was in place? Cloud Storage export, PITR, or JSON/custom backup? For accidental deletion of a few documents in the last 7 days with PITR enabled: use method 3 (PITR). For a mass delete or corruption event where you know the timestamp: use method 3 (PITR) or method 2 (full import) to a test project first. For a specific collection that was corrupted while other data is fine: use method 4 (selective restore via temporary project). Never start a restore on production without first doing a dry run on a test Firebase project.
Expected result: You have a clear restore plan: which method to use, which backup to restore from, and confirmation that you are starting with a test project.
Full restore from a Cloud Storage export
Full restore from a Cloud Storage export
If you have a Cloud Storage export created via Firebase Console → Firestore → Import/Export or via a Cloud Function using admin.firestore().exportDocuments(), restore it with: firebase firestore:import gs://your-backup-bucket/backup-folder (using Firebase CLI after code export from FlutterFlow, or via gcloud CLI). Alternatively, in Google Cloud Console → Firestore → Import/Export → Import, enter the gs:// path of the export. WARNING: this operation overwrites ALL existing Firestore data. Any documents written after the backup was created will be permanently deleted. Always test on a dev Firebase project first by importing there and verifying the data looks correct before restoring production.
Expected result: The Firestore database contains all documents from the backup. Documents created after the backup was taken are gone — this is expected behavior.
Use point-in-time recovery (PITR) for recent accidental changes
Use point-in-time recovery (PITR) for recent accidental changes
PITR is the easiest restore method if your Firestore is in Native mode and PITR is enabled (Firebase Console → Firestore → Settings → Point-in-time recovery → Enable). PITR maintains a 7-day history of your database state. To restore: In Firebase Console → Firestore → Recovery, click Restore database. Select a timestamp (e.g., 2 hours before the accidental deletion). Choose a target: either restore to the current database (overwrites current data) or create a new database at that point-in-time. The 'create new database' option is safer — it creates a parallel database you can inspect before deciding to switch traffic to it. PITR restores can take 1-4 hours depending on database size.
Expected result: A Firestore database instance is created with data as it existed at the chosen timestamp. You can inspect it before directing any traffic to it.
Selective restore for specific collections without overwriting everything
Selective restore for specific collections without overwriting everything
When only part of your database needs restoring (e.g., the orders collection was accidentally cleared but users and products are fine), avoid a full restore that would also roll back recent legitimate changes to other collections. Instead: (1) Import the backup to a new temporary Firebase project (create one free in Firebase Console). (2) In the temporary project, run a Cloud Function that reads the specific collection and writes each document to your production project using the Firebase Admin SDK with admin.initializeApp(productionCredentials). (3) Query Firestore in the temp project: await sourceDb.collection('orders').get(). (4) For each document, write to production: await productionDb.collection('orders').doc(doc.id).set(doc.data()). This overwrites only the orders collection while leaving all others untouched.
1// Cloud Function: restoreCollectionFromBackup2// Run in the TEMPORARY Firebase project pointing at production as destination3const admin = require('firebase-admin');4const sourceDb = admin.firestore(); // temp project DB (backup data)56// productionDb uses service account of the PRODUCTION project7const { initializeApp, cert } = require('firebase-admin/app');8const prodApp = initializeApp({ credential: cert(require('./prod-service-account.json')) }, 'production');9const productionDb = require('firebase-admin/firestore').getFirestore(prodApp);1011async function restoreCollection(collectionName) {12 const snapshot = await sourceDb.collection(collectionName).get();13 const batch = productionDb.batch();14 let count = 0;15 for (const doc of snapshot.docs) {16 batch.set(productionDb.collection(collectionName).doc(doc.id), doc.data());17 count++;18 if (count % 500 === 0) await batch.commit();19 }20 await batch.commit();21 console.log(`Restored ${snapshot.docs.length} documents to ${collectionName}`);22}Expected result: Only the targeted collection is restored from backup. All other Firestore collections remain as they were in production.
Verify the restore before redirecting live traffic
Verify the restore before redirecting live traffic
After any restore operation, run a verification checklist before your FlutterFlow app starts using the restored data: (1) Check document counts match expected values in Firestore Console → collection → document count. (2) Open 5-10 randomly selected documents and verify their fields look correct — especially recently created records that should exist. (3) Test read queries that your FlutterFlow Backend Queries use — verify they return expected data. (4) Test write operations — add a test document, verify it appears, then delete it. (5) Check Firestore Security Rules still work — run the Rules Playground for your key auth scenarios. (6) If you restored to a new database, update the Firestore database ID in your FlutterFlow project (Settings → Firebase → Database ID) and redeploy. Allow 30-60 minutes of observation before considering the restore complete.
Expected result: The restored database passes all verification checks. You are confident data is complete and correct before resuming normal app operations.
Complete working example
1// Cloud Function: verifyRestore2// Checks document counts across collections after a restore3const functions = require('firebase-functions');4const admin = require('firebase-admin');5admin.initializeApp();67exports.verifyRestore = functions.https.onRequest(async (req, res) => {8 const db = admin.firestore();9 const collections = ['users', 'orders', 'products', 'shipments'];10 const report = {};1112 for (const col of collections) {13 const snap = await db.collection(col).count().get();14 report[col] = snap.data().count;15 }1617 // Check for any documents with null required fields18 const invalidOrders = await db.collection('orders')19 .where('userId', '==', null)20 .limit(10)21 .get();2223 report.invalidOrders = invalidOrders.docs.length;24 report.verifiedAt = new Date().toISOString();2526 res.json(report);27});Common mistakes when restoring Your FlutterFlow Firestore Database from a Backup
Why it's a problem: Restoring the full database directly to production without testing on a temp project first
How to avoid: Always import to a temporary Firebase project first. Verify the data looks correct. Only then restore to production. This two-step process is non-negotiable for production restores.
Why it's a problem: Assuming PITR is enabled without verifying
How to avoid: Enable PITR today if your data is critical: Firebase Console → Firestore → Settings → Point-in-time recovery → Enable. It requires Blaze plan. Also set up automated Cloud Storage export backups as a separate safety net.
Why it's a problem: Running a full restore without documenting what production currently looks like
How to avoid: Before any restore, export the current state to a new Cloud Storage bucket with a timestamp: admin.firestore().exportDocuments({outputUriPrefix: 'gs://bucket/pre-restore-' + Date.now()}). This gives you a rollback path.
Best practices
- Enable Firestore PITR immediately for production apps — it is the fastest and safest restore method for recent incidents
- Run automated daily backups via Cloud Scheduler + Cloud Function exporting to Cloud Storage, retained for at least 30 days
- Test your restore procedure quarterly on a dev project — discovering that your backup is corrupted during an actual outage is far worse than finding it during a routine drill
- Keep multiple backup generations — daily for 7 days, weekly for 4 weeks, monthly for 12 months — different incidents require different lookback periods
- Document which service account credentials are needed for restore operations and store them securely outside your Firebase project
- After a restore, immediately audit Firestore Security Rules — some rules are stored as part of the deployed project configuration, not in the database, and must be redeployed if the project was recreated
- Set up monitoring alerts in Google Cloud for failed backup export jobs — a backup that silently fails for 2 weeks means you have no recent backup when disaster strikes
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I accidentally deleted a collection from my Firestore database used by a FlutterFlow app. I have an automated backup stored in a Cloud Storage bucket as a Firestore export. Walk me through: (1) how to import the backup to a temporary Firebase project, (2) how to selectively copy only the deleted collection back to my production project using a Cloud Function with the Firebase Admin SDK, and (3) how to verify the restore was successful by checking document counts and field integrity.
My FlutterFlow app's Firestore database had some orders accidentally deleted. I want to restore them from a Cloud Storage backup without affecting other collections. Help me write a Cloud Function that reads the orders collection from a backup project (I'll specify the project ID) and writes each document to my production project's orders collection using the Admin SDK.
Frequently asked questions
How do I restore my FlutterFlow database from a backup?
The method depends on your backup type. If you have a Cloud Storage export, use the Firebase Console → Firestore → Import/Export → Import and point to the gs:// path. If PITR is enabled, use Firebase Console → Firestore → Recovery to restore to a specific timestamp. For selective recovery without a full overwrite, import the backup to a temporary Firebase project and copy only the needed collections via a Cloud Function.
What is Firestore point-in-time recovery and how do I enable it?
PITR maintains a rolling 7-day history of your Firestore database, allowing you to restore to any second within that window. Enable it in Firebase Console → Firestore → Settings → Point-in-time recovery → Enable. It requires the Blaze pay-as-you-go plan and adds a small storage cost for maintaining the history. Enable it before you need it — you cannot retroactively access history from before PITR was enabled.
Can I restore just one Firestore collection without affecting the rest of my database?
Yes, using selective restore. Import your backup to a temporary Firebase project. Write a Cloud Function that reads the specific collection from the temp project and writes each document to your production project using the Admin SDK. This leaves all other collections unchanged. It requires creating a service account for cross-project access.
How long does a Firestore database restore take?
A full import restore for a small database (under 100MB) typically takes 5-15 minutes. Larger databases (1GB+) can take 1-4 hours. PITR restores are comparable in time. There is no way to estimate progress during the restore — the Firebase Console shows it as in-progress until complete. Plan maintenance windows accordingly.
What if I do not have any backups set up?
If PITR is not enabled and no Cloud Storage exports exist, your recovery options are limited. Check if any read operations cached data in your FlutterFlow app's offline Firestore persistence on user devices. Check if any third-party services (email services, payment processors) received copies of the data that can be re-imported. Going forward, enable PITR and set up automated daily exports immediately.
What if I need help recovering data or setting up a proper backup strategy?
Data recovery and backup architecture for production apps requires careful planning around retention policies, security, and disaster recovery testing. RapidDev has helped teams recover from Firestore data loss incidents and can set up a robust automated backup and restore procedure for your FlutterFlow app.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation