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?
2 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
- 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. - 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 selectFirebase Rules System
from theOther
category. - Get your Google Storage URL from the Firebase Storage Page in the dashboard (Towards the top) Should look something like this:
gs://<bucket_name>
- 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
- 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.
- 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.

- 2,135
- 2
- 25
- 35
-
I don't know why this didn't get any upvotes, but this works perfectly well. Thanks! – michaelk Dec 19 '17 at 05:05
-
Thank you very much @auzy. IT WORKS PERFECTLY. For you guys, don't forget this : `Make sure you are in the folder you want as the following command will download all files right there in current folder`. – Steffi Feb 17 '20 at 09:57
-
Backup is only half the requirement though. I use FB RTDB and Storage to hold images associated with records on RTDB. In my app, the images are accessed using url+token stored on RTDB. However, if there is data loss and I have to restore the FB Storage bucket, FB creates new tokens for the images, so they are no longer linked to the FB RTDB records and it is completely impractical to fix the links manually. Any one found a way of doing successful restores?. – GrahamD Dec 24 '20 at 14:05
-
Once I have all the files downloaded how can I upload them recursively through one command? – Lukas Luke Stateczny Jan 15 '21 at 12:57
-
1@LukasLukeStateczny `gsutil -m cp -r
gs:// – Auzy Jan 20 '21 at 04:35`. I'd double-check on the [Google Cloud Docs](https://cloud.google.com/storage/docs/gsutil/commands/cp) to make sure it works for your setup but that's the general use case. -
@Auzy Thanks a million :) – Lukas Luke Stateczny Jan 20 '21 at 21:24
-
@GrahamD to restore tokens for old url you can use this `final storageRef = FirebaseStorage.instance.refFromURL(oldTokenUrl); newUrl = await storageRef.getDownloadURL();` – Ilya K Mar 05 '23 at 16:52
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
- Access to your Project at Google Cloud Storage
- At Browser tab, select the Bucket that has your files.
- 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.

- 21
- 2