Cookie Consent by Free Privacy Policy Generator 📌 How to programmatically backup your Firestore database with simple steps


✅ How to programmatically backup your Firestore database with simple steps


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

Why this post? Recently, Google Cloud announced in preview a way to automatically setup and schedule your Firestore backups. Prior to the announcement, the recommended approach required multiple serverless components, such as Cloud Functions and Cloud Scheduler.

At the time this post was written, there was no public documentation around how to use Google Cloud APIs to run the aforementioned feature, but using gcloud:
Image description

How to do it programmatically with Python

Many users are not aware, but sometimes the newest API operations or available features are not immediately available on Google SDKs, but you have something they call discovery API client:

In summary, the Google API Discovery service simplifies the process of working with Google APIs by providing structured and standardized documentation, which under the hood is utilized by their client libraries:
Image description

Basically, it's a document that tells machines how to interact with their APIs, which sometimes can be helpful as documentation. I recommend always using each of Google's SDK services and relying on the discovery client if the operation is unavailable in the SDK or if you want to get more details on what is available for that service with its models.

Then how to use it?

First, start by installing the google-api-python-client PyPI package.

Image description

Next, after looking at the discovery JSON that you can get in this link, and finding what is the right service and operation you need to call, you build the service object:

Image description

Then, by inspecting what the gcloud command was doing, I got to the service I needed:

Image description

The full code sample is here; I hope it helps!

import googleapiclient.discovery

# change to your project and db ids
project_id = "MY_PROJECT_ID"
database_id = "MY_FIRSTORE_DB_ID"

api_service_name = "firestore"
api_version = "v1"
discovery_url = f"https://{api_service_name}.googleapis.com/$discovery/rest?version={api_version}"
service = googleapiclient.discovery.build(
    api_service_name, api_version, discoveryServiceUrl=discovery_url
)
created_backup = (
    service.projects()
    .databases()
    .backupSchedules()
    .create(
        parent=f"projects/{project_id}/databases/{database_id}",
        body={
            "retention": "604800s",
            "dailyRecurrence": {},
        },
    )
    .execute()
)

I chose 604800s, equivalent to 7 days, and dailyRecurrence which doesn't require any payload attributes for daily backups. If you are looking to schedule it weekly, you may change dailyRecurrence to something like this:

"weeklyRecurrence": {
  # day of week enum
  "day": "MONDAY"
}
...

✅ How to programmatically backup your Firestore database with simple steps


📈 75.78 Punkte

✅ Fiyo CMS 2.0.1.8 Database Backup .backup/ Backup File information disclosure


📈 28.76 Punkte

✅ Fiyo CMS 2.0.1.8 Database Backup .backup/ Backup File Information Disclosure


📈 28.76 Punkte

✅ Simple ML for Sheets, new Firestore features, and more dev news!


📈 26.22 Punkte

✅ Backup Sanity with Cloud Firestore


📈 26.17 Punkte

✅ Programmatically deploy your GitHub Repo on Netlify


📈 25.9 Punkte

✅ Analyze your builds programmatically with the C++ Build Insights SDK


📈 25.9 Punkte

✅ Programmatically change your system’s mic and speakers with NirCmd and Elgato StreamDeck


📈 25.9 Punkte

✅ How to Restart your App Programmatically


📈 25.9 Punkte

✅ Firebase Realtime Database vs Cloud Firestore


📈 25.73 Punkte

✅ React & TypeScript: How to use Context API and useReducer with Firestore Database?


📈 25.73 Punkte

✅ FireQL - Query Google Firestore database using SQL syntax.


📈 25.73 Punkte

✅ FireStorePwn - Firestore Database Vulnerability Scanner Using APKs


📈 25.73 Punkte

✅ Google Updates Cloud Firestore NoSQL Database Beta for GCP


📈 25.73 Punkte

✅ Creating videos programmatically with Remotion on The Download


📈 22.79 Punkte

✅ Programmatically add a new 'Accepted file extension'


📈 22.79 Punkte

✅ MySQL Dual Passwords – How To Manage Them Programmatically


📈 22.79 Punkte

✅ My journey through programmatically creating Umbraco `stuff`


📈 22.79 Punkte

✅ Vulcan - Exposing Eclipse JDT Programmatically


📈 22.79 Punkte

✅ How to check programmatically when a filesystem goes south.


📈 22.79 Punkte

✅ How to Programmatically Cancel MRP Records in Odoo


📈 22.79 Punkte

✅ Resolv.conf not modifying programmatically but has no issues on manual editing.


📈 22.79 Punkte

✅ Add alternate contacts to AWS Organization member accounts programmatically


📈 22.79 Punkte

✅ Programmatically Disconnect Device From Another Device


📈 22.79 Punkte

✅ Programmatically Setting File Inputs in JavaScript


📈 22.79 Punkte

✅ Programmatically Navigate Using React Router and Hooks


📈 22.79 Punkte

✅ Programmatically Setting File Inputs in JavaScript


📈 22.79 Punkte

✅ How to ( programmatically ) tell who is running "the" window manager?


📈 22.79 Punkte

✅ Configure XFCE 4 programmatically with the help of watch-xfce-xfconf


📈 22.79 Punkte

✅ Implementing Wildcard Subdomain (Part 2) - Creating subdomain programmatically


📈 22.79 Punkte

✅ How could i start a software and inject a String so i can later programmatically fetch it (i'll use python)


📈 22.79 Punkte

✅ How to Send Ethers Programmatically without Metamask


📈 22.79 Punkte











matomo

Datei nicht gefunden!