Google Datastore backup restore to default database

168 views Asked by At

I'm looking at the new Backup and restore data functionality for Google Datastore (and Firestore), currently in Preview.

The Restore data from a database backup part instructs on how to restore a backup to a new database:

gcloud alpha firestore databases restore \
    --source-backup=projects/PROJECT_ID/locations/LOCATION/backups/BACKUP_ID \
    --destination-database='DATABASE_ID'

DATABASE_ID: A database ID for the new database. You cannot use a database ID that is already in use. The database mode will match that of the backup.

What is the point in this? I understand these are intended (also) for Disaster Recovery:

Use backups to protect your data from application-level data corruption or from accidental data deletion.

So in case my application suddenly gets his (default) database corrupted what am I supposed to do? Restore a backup in another database? Re-configure my application to use another database from (default) could take me more time.

Plus I cannot simply get rid of the corrupted (default) database deleting it because, I read:

For the (default) database only, you must delete all related backups before you can delete the database.

Exporting and Importing Entities exports to a Google Cloud Storage bucket you can re-import to the same database right after. So does Point-in-time recovery, why scheduled backups do not?

I know I could restore to a different database, export to GCS and then import to (default), time is critical in a Disaster Recovery it would be simpler having a direct option, is it available somewhere?

2

There are 2 answers

2
Roopa M On

This concern is already discussed here and They mentioned that

The Firebase backup feature is currently in Alpha, so the recovery process is not yet finalized.

However, you can try one of the approaches they mentioned, if it matches your requirement.

Point your users to the new database instance. This would require you to push a new version of your app that uses the new database connection string. It would also mean that your users would no longer be able to take advantage of the free limits for the default database instance.

If you are not satisfied with this. You can raise feature request for the same in public issue tracker by adding your concern.

5
Jim Morrison On

Your options to fix an issue in your default database from a backup are:

  1. Restore to a new database, and use a tool like dataflow to repair the entities that need to be fixed.
  2. Delete your default database (this does not require deleting backups anymore), then restore into the default database
  3. Restore into a new database and point your clients to the new database.

Depending on what problem you are solving for (1 bad entity) vs I already deleted all my data vs I don't know what problem exists, you may pick any of the above solutions.