Back up and restore data

This page describes how to use theCloud Firestore scheduled backupsfeature. Use backups to protect your data from application-level datacorruption or from accidental data deletion.

Backups let you configure backup schedules to take daily or weeklybackups of the specified database. You can then use these backups to restoredata to a new database.

About backups

A backup is a consistent copy of the database at a point in time.The backup contains all data and index configurations at that pointin time.

A backup does not contain databasetime to live policies.A backup resides in the same location as the source database.

Backups have a configurable retention period and are stored until the retentionperiod expires or until you delete the backup. Deleting the source database doesnot automatically delete related backups.

Cloud Firestore stores metadata related to backups and backupschedules related to a database.Cloud Firestore retains this metadatauntilall backups for the database expire or are deleted.

Creating or retaining backups does not affect the performance of reads orwrites in your live database.

Costs

When you use backups, you're charged for the following:

  • The amount of storage used by each backup.
  • For a restore operation, you're charged based on the size of the backup.

For more details and exact rates, see thePricing page.

Before you begin

This feature requires theBlaze pricing plan.

Required roles

To get the permissions that you need to manage backups and backup schedules,ask your administrator to grant you one or more of the following Identity and Access Managementroles:

  • roles/datastore.owner: Full access to theCloud Firestore database
  • roles/datastore.backupsAdmin: Read and write access to backups
  • roles/datastore.backupsViewer: Read access to backups
  • roles/datastore.backupSchedulesAdmin: Read and write access to backup schedules
  • roles/datastore.backupSchedulesViewer: Read access to backup schedules
  • roles/datastore.restoreAdmin: Permissions to initiate restore operations

Create and manage backup schedules

The following examples demonstrate how to set up a backup schedule. For eachdatabase, you can configure up to one daily backup schedule and up to one weeklybackup schedule. You cannot configure multiple weekly backups schedules fordifferent days of the week.

You cannot configure the exact time of day of the backup. Backups are taken atdifferent times each day. For weekly backupschedules, you can configure the day of the week to take a backup.

Create a backup schedule

Use one of the following tools to create a backup schedule.

Create a daily backup schedule

Google Cloud console
  1. In the Google Cloud console, go to theDatabases page.

    Go to Databases

  2. In the list of databases, find the row for the database. In theScheduled backups column click eitherView backups orEdit settings, depending on whether a backup schedule exists.
  3. ClickEdit to edit disaster recovery settings.
  4. Select theDaily checkbox, set the retention period, and then clickSave.
Firebase CLI
To create a backup schedule for a database, use thefirebase firestore:databases:backups:schedules:create command.To create a daily backup schedule, set the--recurrence flag toDAILY:
firebase firestore:backups:schedules:create \--database 'DATABASE_ID' \--recurrence 'DAILY' \--retentionRETENTION_PERIOD

Replace the following:

  • DATABASE_ID: The ID of the database to back up. Set to'(default)' for the default database.
  • RETENTION_PERIOD: Set this to a value up to 14 weeks (14w).
Terraform
To create a daily backup schedule, create agoogle_firestore_backup_schedule resource.
resource"google_firestore_backup_schedule""daily-backup"{project=PROJECT_IDdatabase=DATABASE_IDretention=RETENTION_PERIOD_SECONDSdaily_recurrence{}}

Replace the following:

  • PROJECT_ID: The ID of the project.
  • DATABASE_ID: The ID of the database to back up. Set to'(default)' for the default database.
  • You can also use aresource reference to a Terraform resource of typegoogle_firestore_database.
  • RETENTION_PERIOD_SECONDS: Set this to a value in seconds, followed by "s". The maximum value is8467200s (14 weeks).

Create a weekly backup schedule

Google Cloud console
  1. In the Google Cloud console, go to theDatabases page.

    Go to Databases

  2. In the list of databases, find the row for the database. In theScheduled backups column click eitherView backups orEdit settings, depending on whether a backup schedule exists.
  3. ClickEdit to edit disaster recovery settings.
  4. Select theWeekly checkbox, select a backup day, set the retention period, and then clickSave.
Firebase CLI
To create a weekly backup schedule, set the--recurrence flag toWEEKLY and choose the--day-of-week:
firebase firestore:backups:schedules:create \--database 'DATABASE_ID' \--recurrence 'WEEKLY' \--retentionRETENTION_PERIOD--day-of-weekDAY
Replace the following:
  • DATABASE_ID: The ID of the database to back up. Set to'(default)' for the default database.
  • RETENTION_PERIOD: Set this to a value up to 14 weeks (14w).
  • DAY: The day of the week to take the backup. Set to one of the following:
    • SUNDAY for Sunday
    • MONDAY for Monday
    • TUESDAY for Tuesday
    • WEDNESDAY for Wednesday
    • THURSDAY for Thursday
    • FRIDAY for Friday
    • SATURDAY for Saturday
Terraform
To create a weekly backup schedule, create agoogle_firestore_backup_schedule resource.
resource"google_firestore_backup_schedule""weekly-backup"{project=PROJECT_IDdatabase=DATABASE_IDretention=RETENTION_PERIOD_SECONDSweekly_recurrence{day=DAY}}

Replace the following:

  • PROJECT_ID: The ID of the project.
  • DATABASE_ID: The ID of the database to back up. Set to'(default)' for the default database.
  • You can also use aresource reference to a Terraform resource of typegoogle_firestore_database.
  • RETENTION_PERIOD_SECONDS: Set this to a value in seconds, followed by "s". The maximum value is8467200s (14 weeks).
  • DAY: The day of the week to take the backup. Set to one of the following:
    • SUNDAY for Sunday
    • MONDAY for Monday
    • TUESDAY for Tuesday
    • WEDNESDAY for Wednesday
    • THURSDAY for Thursday
    • FRIDAY for Friday
    • SATURDAY for Saturday

List backup schedules

To list all backup schedules for a database, use one of the following methods:

Google Cloud console
  1. In the Google Cloud console, go to theDatabases page.

    Go to Databases

  2. In the list of databases, find the row for the database. In theScheduled backups column click eitherView backups orEdit settings, depending on whether a backup schedule exists.
  3. TheDisaster recovery page opens. This page describes backup schedulesand lists available backups.
Firebase CLI
Use thefirebase firestore:backups:schedules:list command.
firebase firestore:backups:schedules:list \--database 'DATABASE_ID'
ReplaceDATABASE_ID with the ID of the database. Use'(default)' for the default database.

Describe backup schedule

To retrieve information about a backup schedule, use one of the following methods:

Google Cloud console
  1. In the Google Cloud console, go to theDatabases page.

    Go to Databases

  2. In the list of databases, find the row for the database. In theScheduled backups column click eitherView backups orEdit settings, depending on whether a backup schedule exists.
  3. TheDisaster recovery page opens. This page describes backup schedulesand lists available backups.
gcloud
Use thegcloud firestore backups schedules describe command:
gcloud firestore backups schedules describe \--database='DATABASE_ID' \--backup-schedule=BACKUP_SCHEDULE_ID
Replace the following:
  • DATABASE_ID: The ID of the database to back up. Set to'(default)' for the default database.
  • BACKUP_SCHEDULE_ID: The ID of a backup schedule. You can view the ID of each backup schedule when youlist all backup schedules.

Update a backup schedule

To update the retention period of a backup schedule, use one of the following methods:

Google Cloud console
  1. In the Google Cloud console, go to theDatabases page.

    Go to Databases

  2. In the list of databases, find the row for the database. In theScheduled backups column click eitherView backups orEdit settings.
  3. ClickEdit to edit disaster recovery settings.
  4. Edit the backup schedule settings and then clickSave.
Firebase CLI
Use thefirebase firestore:backups:schedules:update command:
firebase firestore:backups:schedules:update \BACKUP_SCHEDULE \--retentionRETENTION_PERIOD
Replace the following:
  • BACKUP_SCHEDULE: The full resource name of a backup schedule. You can view the name of each backup schedule when youlist all backup schedules.
  • RETENTION_PERIOD: Set this to a value up to 14 weeks (14w).

You can update the retention period of a backup schedule, but you cannot update its recurrence. If you need a backup schedule with a different recurrence, delete the old backup schedule if it is no longer required and create a new backup schedule with the preferred recurrence.

Delete a backup schedule

To delete a backup schedule, use one of the following methods:

Google Cloud console
  1. In the Google Cloud console, go to theDatabases page.

    Go to Databases

  2. In the list of databases, find the row for the database. In theScheduled backups column click eitherView backups orEdit settings, depending on whether a backup schedule exists.
  3. ClickEdit to edit disaster recovery settings.
  4. Edit the backup schedule settings and then clickSave.
Firebase CLI
Use thefirebase firestore:backups:schedules:delete command:
firebase firestore:backups:schedules:delete \BACKUP_SCHEDULE
Replace the following:
  • BACKUP_SCHEDULE: The full resource name of a backup schedule. You can view the name of each backup schedule when youlist all backup schedules.

Note that deleting a backup schedule won't delete backups already created bythis schedule. You can wait for them to expire after their retention period, orto manually delete a backup, seedelete backup.

Manage backups

List backups

To list available backups, use one of the following methods:

Google Cloud console
  1. In the Google Cloud console, go to theDatabases page.

    Go to Databases

  2. In the list of databases, find the row for the database. In theScheduled backups column click eitherView backups orEdit settings, depending on whether a backup schedule exists.
  3. ClickEdit to edit disaster recovery settings.
  4. Edit the backup schedule settings and then clickSave.
Firebase CLI
Use thefirebase firestore:backups:list command:
firebase firestore:backups:list
To list only the backups from a specific location, use the--location flag:
firebase firestore:backups:list \--location=LOCATION
ReplaceLOCATION with the name of aCloud Firestorelocation.

Describe a backup

To view details about a backup, use one of the following methods:

Google Cloud console
  1. In the Google Cloud console, go to theDatabases page.

    Go to Databases

  2. In the list of databases, find the row for the database. In theScheduled backups column click eitherView backups orEdit settings, depending on whether a backup schedule exists.
  3. TheDisaster recovery page opens. This page describes backup schedulesand lists available backups.
Firebase CLI
Use thefirebase firestore:backups:get command:
firebase firestore:backups:getBACKUP
Replace the following:
  • BACKUP: The full resource name of a backup. You can view the name of each backup when youlist all backups.

Delete backup

To delete a backup, use one of the following methods.

Warning: You cannot recover a deleted backup.
Google Cloud console
  1. In the Google Cloud console, go to theDatabases page.

    Go to Databases

  2. In the list of databases, find the row for the database. In theScheduled backups column click eitherView backups orEdit settings, depending on whether a backup schedule exists.TheDisaster recovery page opens. This page describes backup schedulesand lists available backups.
  3. In theBackups table, find the row for a backup and in theActions column, clickView more(). ClickDelete.
  4. Confirm the action using the text field and clickDelete.
Firebase CLI
Use thefirebase firestore:backups:delete command:
firebase firestore:backups:delete \BACKUP
Replace the following:
  • BACKUP: The full resource name of a backup. You can view the name of each backupwhen youlist all backups.
Note:Cloud Firestore stores metadata related to backups and backupschedules related to a database.Cloud Firestore retains this metadatauntilall backups for the database expire or are deleted.

Restore data from a database backup

A restore operation writes the data from a backup to a newCloud Firestoredatabase.

To begin a restore operation, use one of the following methods:

Google Cloud console
  1. In the Google Cloud console, go to theDatabases page.

    Go to Databases

  2. In the list of databases, find the row for the database. In theScheduled backups column click eitherView backups orEdit settings, depending on whether a backup schedule exists.TheDisaster recovery page opens. This page describes backup schedulesand lists available backups.
  3. In theBackups table, find the row for a backup and in theActionscolumn, clickView more(). ClickRestore withCloud Shell.
  4. TheCloud Shell panel opens with agcloud CLI commandto restore from the selected backup. ReplaceID_OF_NEW_DATABASE withan ID for the database and run the command.

    Running the command returns a response with more information about theoperation. The database soon appears in your list of databases. The restoreoperation will take some time and must complete before the database is accessible.

Firebase CLI
Use thefirebase firestore:databases:restore command:
firebase firestore:databases:restore \--backup 'BACKUP' \--database 'DATABASE_ID'
Replace the following:
  • BACKUP: The full resource name of a backup. You can view the name of each backup when youlist all backups.
  • DATABASE_ID: A database ID for the new database. You cannot use a database ID that is already in use.

Limitations

A restore operation does not restoreApp Engine search data orblob entities from a(default) database. This data is only valid for the(default) database, and it won't be useful if you restore from(default) to a database which does not support such data, so it is excluded from backups.

What to do after restoring

After you finish restoring, you should do the following:

  • Verify that appropriateIAM controls are applied to your new database.

  • If you previously usedTTL policies, reapply them to the new database. TTL policies are not included in backups and are not automatically reapplied to restored databases.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.