Setup

You can set up database backups from the Backups tab of the Realtime Database of Firebase section. The setup wizard will guide you through the steps to configure automatic backups. Your Database backup activity will happen at a specific hour each day without affecting the load and ensures the highest availability for all backup customers.

Additionally, you can also take a manual backup whenever you want to get a point in time snapshot of your data and rules.

Your backups will be stored in Google Cloud Storage, which is an object storage service provided by Google Cloud Platform. Essentially, Google Cloud Storage provides buckets that are like directories on computer filesystem, in which your backups will be stored. So, once the setup is done, a bucket will be created with permissions where your Firebase can write the data. We will see Google Cloud Storage and Firebase Cloud Storage in detail in Chapter 8, Firebase Cloud Storage.

The backup service automatically compresses the backup files using Gzip compression that reduces the overall backup size and ultimately reduces cost and also minimizes data transfer time. The compressed file size varies based on the data in your database, but in general, it reduces the overall file size to 1/3 of the original decompressed file size. You can enable and disable Gzip compression based on your requirements.

To save further cost, you can also you can enable a 30-day lifecycle policy on your bucket to delete older backups; for example, backups older than 30 days automatically get deleted.

Your Gzipped JSON files can be decompressed by executing the following command-line command using the gunzip binary, which is available by default on OS-X and most Linux distributions:

gunzip <DATABASE_NAME>.json.gz

The filenames will be generated based on the following naming conventions. It will have a timestamp (ISO 8601 Standard):

Database data: YYYY-MM-DDTHH:MM:SSZ_<DATABASE_NAME>_data.json
Database rules: YYYY-MM-DDTHH:MM:SSZ_<DATABASE_NAME>_rules.json

If you have Gzip compression enabled, the name will be appended by a .gz suffix.

Consider this example:

 Database data: YYYY-MM-DDTHH:MM:SSZ_<DATABASE_NAME>_data.json.gz
Database rules: YYYY-MM-DDTHH:MM:SSZ_<DATABASE_NAME>_rules.json.gz

Once you have taken a backup, you would want to restore it at some point in time. Let's check how we can restore the data from a backup.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset