Backing up Firebase project with Github Actions

Backups are really useless most of the time… until something goes wrong and you really need one.

Dennis Alund
oddbit
Published in
2 min readApr 25, 2020

--

This article will help provide some easy to apply recipes to back up your Firebase project, in a single Github Action workflow.

To implement this workflow you will be needing

  1. Firebase token for CI/CD deployment.
  2. Service account that can access your Firebase project and storage buckets.

We will be making a snapshot backup that is being replaced for each run and another accumulative one that is adding every new backup into an historical archive.

Make sure that your GCP project has a “backups bucket”. It should be listed in your Google Cloud Platform Console, but not in the Firebase console. Replace example in the URL below to check and confirm.

https://console.cloud.google.com/storage/browser?project=example

If your project ID is example, then you should have a bucket called example-backups.

The bucket is automatically created if you have already configured Firebase Database automated backups before. You can configure to switch them on right away to get two-for-one: both having the bucket generated and benefits of automated backups.

We will be using this bucket to store our own backups too.

/.github/workflows/backup-snapshot.yml

The schedule for your snapshot backups is up to you on how frequent you find it necessary. In this example we’re making a nightly snapshot of the project.

/.github/workflows/backup-archive.yml

The schedule for your archive backups is also up to your own needs, depending on how frequent you find it necessary. In this example we’re making a monthly backup archive of the project.

Finally

Sleep well knowing that your project is backed up on a regular basis.

Originally published at https://dennis.alund.me on April 25, 2020.

--

--

Dennis Alund
oddbit
Editor for

Google Developer Expert for Firebase, nerd and passionate problem solver | Founder of Kumpul coworking space in Bali