alpine-firestore-backup
alpine-firestore-backup copied to clipboard
Image that performs Firestore backups based on Alpine Google Cloud SDK image.
Supported tags and respective Dockerfile links
latest,268.0.0(Dockerfile)- from
267.0.0to256.0.0(all listed versions here)
alpine-firestore-backup
Image that performs Firestore backups based on google/cloud-sdk:alpine image.
Why this image
We use a lot of Firebase features like Firestore. But there is no simple way to backup the data.
This image aims to be used inside the Google Cloud Platform to perform backups automatically.
See this article for more information.
Prerequisites
Create a bucket on GCP
Create a GCP coldline bucket and save the name of your bucket.
Create a service account
Create a GCP Service account with the following rights:
Cloud Datastore Import Export AdminStorage Admin
Prepare your env variables for Cloud Run
Please fill in the following information:
GCLOUD_PROJECT_IDGCLOUD_BUCKET_NAME
3 ways to create your image ready to use on Cloud Run
1. Use the Cloud Run Button
Please give a feedback on this new way to deploy it ✨
For this deployment, the new service account can't be used. Simply grant the default (<project_id>[email protected]) service account with the required roles
2. Use a public image
You can use the public gcr image available on gcr.io/zenika-hub/alpine-firestore-backup
We publish the image in the 4 container registries to be available in the closest region:
- Global:
gcr.io/zenika-hub/alpine-firestore-backup - Europe:
eu.gcr.io/zenika-hub/alpine-firestore-backup - Asia:
asia.gcr.io/zenika-hub/alpine-firestore-backup - US:
us.gcr.io/zenika-hub/alpine-firestore-backup
3. Create your own image
You can also create your own image from the repository to be independant. But you have to maintain the update of your image by yourself.
To do this, clone this repository:
git clone https://github.com/zenika/alpine-firestore-backup.git
Build:
docker image build -t gcr.io/[GCLOUD_PROJECT_ID]/alpine-firestore-backup
Push using Container Registry Authentication:
gcloud auth configure-docker
docker push gcr.io/[GCLOUD_PROJECT_ID]/alpine-firestore-backup
3 ways to set up your Cloud Run service
Cloud Run is a serverless service to automatically serve your containers using http.
1. Use the Cloud Run Button
It will deploy it automatically.
2. Use the CLI
If you're fan of CLI, please use the following command to create your Cloud Run service:
gcloud beta run deploy alpine-firestore-backup\
--project=my-awesome-project\
--platform=managed\
--region=europe-west1\
--image=zenika-hub/alpine-firestore-backup\
--memory=256Mi\
--allow-unauthenticated\
--set-env-vars GCLOUD_PROJECT_ID=VALUE,GCLOUD_BUCKET_NAME=VALUE\
--service-account=my-service-account@my-awesome-project.iam.gserviceaccount.com
Check the deployment using the following command:
gcloud beta run services list\
--project my-awesome-project\
--platform managed\
--region=europe-west1\
3. Use the WebUI
In the WebUI console, create a Cloud Run service using the public image gcr.io/zenika-hub/alpine-firestore-backup or your own image gcr.io/[GCLOUD_PROJECT_ID]/alpine-firestore-backup.
Be careful to:
- Choose your newly image in
latest - Choose "Cloud Run (fully managed)" and a location
- Enter a service name
- Select "Allow unauthenticated invocations"
- In the "Show optional settings / Environment variables", set the 3 environment variables seen in the previous section
- In the "Service account" part, select your previously created service account

Test and validate
You can test the service using your browser: https://alpine-firestore-backup-XXX-run.app/
Save the url created to call your Cloud Run Service.
For example: https://alpine-firestore-backup-XXX-run.app/backup
Schedule it with Cloud Scheduler
Cloud Scheduler allow you to schedule a cronjob in order to call a https endpoint at regular intervals.
Prepare a Cloud Scheduler to send a request to your Cloud Run Service every time you need.
For example, every Monday at 3:00am 0 3 * * 1

Monitor the backup operations
You can also check the current status of each backup operation using the following url https://alpine-firestore-backup-XXX-run.app/list