Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Storage - How to setup a backup

Can someone please advise how to setup a backup for Files in Firebase storage. I am able to make a backup of Database but not sure how to setup a regular backup for files (I have images) in firebase storage.

enter image description here

like image 908
Umair Cheema Avatar asked Sep 26 '17 06:09

Umair Cheema


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

  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 121
Auzy Avatar answered Nov 15 '22 09:11

Auzy


Use Google Cloud Transfer Service.

  1. Select your current project
  2. Create Transfer Job
  3. Select source (storage bucket url)
  4. Select destination (click browse and create new bucket)
  5. Use created bucket URL as destination
  6. Configure transfer settings (This is where you can schedule how often the backup runs.)
  7. Click "Create"

If you follow the wizard in the link it will guide you through pretty easily.

like image 29
tbone849 Avatar answered Nov 15 '22 11:11

tbone849