'Export firestore data by overwriting existing data gcloud firestore

I am trying to overwrite existing export data in gcloud using:

gcloud firestore export gs://<PROJECT>/dir --collection-ids='tokens'

But I get this error:

(gcloud.firestore.export) INVALID_ARGUMENT: Path already exists: /fcm-test-firebase.appspot.com/dir/dir.overall_export_metadata

Is there anyway to either delete the path or export with replace?



Solution 1:[1]

You can easily determine the list of available flags for any gcloud.

Here are variants of the command and you can see that there's no overwrite option:

Because the export is too a Google Cloud Storage (GCS) bucket, you can simply delete the path before attempting the export.

BE VERY CAREFUL with this command as it recursively deletes objects

gsutil rm -r gs://<PROJECT>/dir

BE VERY CAREFUL with this command as it recursively deletes objects

If you would like Google to consider adding an overwrite feature, consider filing a feature request on it's public issue tracker.

I suspect that the command doesn't exist for various reasons:

  1. GCS storage is cheap
  2. Many backup copies is ?>> no backup copies
  3. It's easy to delete copies using gsutil

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DazWilkin