【问题标题】:Can I export Firestore data to a local file path instead of a Cloud Storage path?我可以将 Firestore 数据导出到本地文件路径而不是 Cloud Storage 路径吗?
【发布时间】:2020-12-02 13:04:46
【问题描述】:

我使用此代码将 Firestore 数据导出到存储桶文件夹:

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://PROJECT_NAME.firebaseio.com"
});

const client = new admin.firestore.v1.FirestoreAdminClient({});

async function doFirestoreBackup() {
  try {
    const response = await client.exportDocuments({
      name: client.databasePath('PROJECT_NAME','(default)'),
      outputUriPrefix: 'gs://PROJECT_NAME.appspot.com/firestore-backups/2020-12-02-T-12H00/'
    });
    console.log(response);
  }
  catch(err) {
    console.log(err.msg);
  }
}

我可以以某种方式将导出的数据保存到我 PC 上的本地路径吗?而不是在outputUriPrefix上使用存储桶文件夹?

这是我找到的相关文档,但我不明白我想要的是否可行:

https://googleapis.dev/nodejs/firestore/latest/google.firestore.admin.v1.FirestoreAdmin.html#exportDocuments1

https://googleapis.dev/nodejs/firestore/latest/google.firestore.admin.v1.ExportDocumentsRequest.html

https://googleapis.dev/nodejs/firestore/latest/google.firestore.admin.v1.ExportDocumentsResponse.html

【问题讨论】:

    标签: node.js firebase google-cloud-firestore


    【解决方案1】:

    exporting data 上的 Firestore 文档以:

    导出操作会将数据库中的文档复制到 Cloud Storage 存储分区中的一组文件中。

    因此,似乎可以肯定它只能导出到 Cloud Storage 存储分区。如果您想在本地获取导出的数据,您必须先运行导出过程,然后使用gcloud CLLI 之类的工具或通过 Cloud Storage API 将数据从存储桶检索到本地系统。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-29
      相关资源
      最近更新 更多