Blaze plan users can set up their Firebase Realtime Database for automatic backups, a self-service feature that enables daily backups of your Database application data and rules in JSON format to a Google Cloud Storage bucket.
To get started, visit the Backups tab in the Database section of the Firebase console, and the wizard will guide you through setting up your automated backups.
You can view the status and backup activity directly in the Firebase console where you can also start a manual backup. This can be useful for taking specific timed snapshots or as a safety action before you perform any code changes.
Once set up, a new Google Cloud Storage bucket will be created for you with the WRITER permission for Firebase. You should not store data in this bucket you are not comfortable with Firebase having access to. Firebase will have no additional access to your other Google Cloud Storage buckets or any other areas of Google Cloud.
Restoring from backups
To restore your Firebase from a backup, first download the file from Google Cloud Storage to your local disk. This can be done by clicking the filename within the backup activity section or from the Google Cloud Storage bucket interface. If the file is Gzip compressed, first decompress the file.
There are two ways you can import your data:
Method 1: Click the Import JSON button in your Database’s Data section and select your application data JSON file.
Method 2: You can also issue a CURL request from your command line.
First retrieve a secret from your Firebase, which you can get by visiting the Database settings page.
Then enter the following into your terminal, replacing the
SECRET fields with your own values:
curl ‘https://<DATABASE_NAME>.firebaseio.com/.json?auth=<SECRET>&print=silent’ -x PUT -d @<DATABASE_NAME>.json
If you are having trouble restoring a backup from a very large database, please reach out to our support team.
Your Database backup is assigned to a specific hour each day that ensures even load and highest availability for all backup customers. This scheduled backup will occur regardless of if you do any manual backups throughout the day.
Files transferred to your Google Cloud Storage bucket will be timestamped (ISO 8601 standard) and use the following naming conventions:
- Database data:
- Database rules:
is enabled, a
.gz suffix will be appended to the filenames. You can
easily find the backups from a specific date or time using Google Cloud Storage
By default, we compress your backup files using Gzip compression to save on storage costs and decrease transfer times. The compressed filesize varies depending on the data characteristics of your Database, but typical Databases may shrink to ⅓ their original size, saving you on storage costs and decreasing the upload time for your backups.
To decompress your Gzipped JSON files, issue a command line command using the
gunzip binary which is shipped by default for OS-X and most Linux
gunzip <DATABASE_NAME>.json.gz # Will unzip to <DATABASE_NAME>.json
Storage 30 day lifecycle
We offer an easy to use configuration switch that enables a default 30 day object lifecycle policy for your Google Cloud Storage Bucket. When enabled, files in your bucket will be automatically deleted after 30 days. This helps to reduce unwanted old backups, saving you on storage costs, and keeping your bucket directory clean. If you place other files into your Automated Backups bucket, they will also be deleted with the same policy.
The backups feature can be enabled for Blaze customers for no additional cost. However, you will be charged at the standard rates for the backup files placed in your Google Cloud Storage bucket. You can enable Gzip Compression and Storage 30 day Lifecycle to reduce your storage costs.