Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a way to backup data in Firebase Storage?

The auto backup for the Firebase Blaze plan does backup the Firebase Real-Time DB. But I can't find how to backup the Firebase Storage database for the same project where I have daily backups of the RealTime DB. Anyone knows the how to backup Firebase Storage?

like image 759
Adam Je Avatar asked Sep 22 '17 17:09

Adam Je


People also ask

Is Firebase good for Storage?

Cloud Storage for Firebase is a powerful, simple, and cost-effective object storage service built for Google scale. The Firebase SDKs for Cloud Storage add Google security to file uploads and downloads for your Firebase apps, regardless of network quality.

Is Firebase Storage same as Google Cloud Storage?

The new Firebase Storage is powered by Google Cloud Storage, giving it massive scalability and allowing stored files to be easily accessed by other projects running on Google Cloud Platform. Firebase now uses the same underlying account system as GCP, which means you can use any GCP product with your Firebase app.

What is the use of Firebase Storage?

Firebase Storage is a stand-alone solution for uploading user generated content like images and videos from an iOS and Android device, as well as the Web. In typical Firebase fashion, there's no server required. Firebase Storage is designed specifically for scale, security, and network resiliency.


1 Answers

How to make local backup of Firebase Storage

There is no built-in method via Firebase. However, since Firebase uses Google Cloud Storage behind the scenes for Firebase Storage it's possible to use the gutils Tool.

Prerequisites

  • Make sure Python (2.7.9+) is installed on your machine python -V
  • Go to the Google Cloud SDK page and follow the directions to download and install Google Cloud SKD on your OS.

Steps

  1. At the end of the Google SDK installation you should have run gcloud init. This will ask you to select your project and authenticate you. Since Firebase uses Google Cloud Platform behind the scenes your Firebase project should be available as a choice.
  2. In order for Google Cloud Utils to download the files that were uploaded with Firebase permissions you need to give your account Firebase Privileges. Go to the IAM page and select your email address you signed into cloud init with. In the list of available permissions you need to select Firebase Rules System from the Other category.
  3. Get your Google Storage URL from the Firebase Storage Page in the dashboard (Towards the top) Should look something like this: gs://<bucket_name>
  4. In command line on your local machine navigate to the folder you want to do a local backup to. Make sure you are in the folder you want as the following command will download all files right there in current folder
  5. Run the gutil command gsutil -m cp -R gs://<bucket_name> .
    • -m enables multithreading for faster downloads if you have many files.
    • cp is the copy command
    • -R is recursive. If enabled it will download all files and folders in the specified tree.
  6. You're done! This will run for some time depending on the size of your storage.

This can be used to also make a copy(backup) to another Google Cloud Storage Bucket or AWS etc.

like image 57
Auzy Avatar answered Oct 20 '22 09:10

Auzy