Adam Je
Adam Je

Reputation: 181

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?

Upvotes: 17

Views: 7512

Answers (3)

Takuya Matsuda
Takuya Matsuda

Reputation: 93

I was looking for cloud backup methods, but Google cloud storage provides soft delete (protection) feature. The max-soft-delete policy is 90 days. https://cloud.google.com/storage/docs/soft-delete

Upvotes: 0

Timon
Timon

Reputation: 19

I knew that there already have a correct answer 3 years ago by using gsutil in Google Cloud SDK. Here below i just want to add another way to manually download Firebase's Storage, from Google Cloud Storage's Buckets, which are:

  • Not require account billing. (at least by this time)
  • No need to use CLI commands.

But, it DOESNOT allow multiple files / folders download. It just help you to download single file at a time.

Steps

  1. Access to your Project at Google Cloud Storage
  2. At Browser tab, select the Bucket that has your files.
  3. In Bucket Detail page, click arrow-down icon (Download icon) at the end of file's row to download. You can click many times to download many files.

Extra: Google can help you the gsutil command-line to download multiple files and folders at a time. You could try it by select files & folders, and click "Download" text-action on top of the table.

Upvotes: 1

Auzy
Auzy

Reputation: 2155

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.

Upvotes: 43

Related Questions