Firebase存储-如何设置备份 [英] Firebase Storage - How to setup a backup

查看:149
本文介绍了Firebase存储-如何设置备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以建议如何为Firebase存储中的文件设置备份.我可以备份数据库,但不确定如何为Firebase存储中的文件(我有图像)设置常规备份.

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.

推荐答案

如何对Firebase Storage进行本地备份

没有通过Firebase的内置方法.但是,由于Firebase在后台将Google Cloud Storage用于Firebase Storage,因此可以使用 gutils工具.

  • 确保在计算机python -V
  • 上安装了 Python (2.7.9 +)
  • 转到 Google Cloud SDK页面,然后按照说明进行下载和安装您的操作系统上的Google Cloud SKD.
  • 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.
  1. 在安装Google SDK之后,您应该已经运行了gcloud init.这将要求您选择项目并进行身份验证.由于Firebase在后台使用Google Cloud Platform,因此您可以选择Firebase项目.
  2. 要让Google Cloud Utils下载使用Firebase权限上传的文件,您需要给您的帐户Firebase Privileges.转到 IAM页面,然后选择您登录cloud init的电子邮件地址和.在可用权限列表中,您需要从Other类别中选择Firebase Rules System.
  3. 从仪表板的Firebase存储页面获取Google存储URL(朝顶部)应如下所示:gs://<bucket_name>
  4. 在本地计算机上的命令行中,导航到要对其进行本地备份的文件夹. 确保您位于所需的文件夹中,因为以下命令将下载当前文件夹中的所有文件
  5. 运行gutil命令gsutil -m cp -R gs://<bucket_name> .
    • -m如果文件太多,则启用多线程以加快下载速度.
    • cp是复制命令
    • -R是递归的.如果启用,它将下载指定树中的所有文件和文件夹.
  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.

这还可以用于复制(备份)到另一个Google Cloud Storage Bucket或AWS等.

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

这篇关于Firebase存储-如何设置备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆