Scheduling database backup using cloud function

Former Community Member
Not applicable

Hi,

I have been using the code: https://cloud.google.com/datastore/docs/schedule-export
for scheduling backups of my datastore database. It has been working well but we now see a notice that Python 3.7 is being deprecated while the code on the above page seems to be designed only for Python 3.7 and does not seem to work in Python 3.11, gen2.

Also, there is also a requirement to transition to google artifacts registry.

Can someone recommend an updated code which works in Python 3.11 and gen2? Or Python 3.11 and gen1 and transitions to google artifacts registry?

Google team - you might want to flag that the documentation on the above page is now getting obsolete and should be replaced with one for Python 3.11 and google artifacts registry.

1 2 128
2 REPLIES 2

Hi @Former Community Member,

Welcome to Google Cloud Community!

Problem:

  • Old code for datastore backup uses deprecated Python 3.7 and isn't compatible with Gen2 or Artifact Registry.

Solution:

  1. Update Code:

    • Migrate to Python 3.11 compatibility.
    • Use compatible dependencies from Artifact Registry.
    • Update libraries to new versions.
    • Test thoroughly.
  2. Deployment Environment:

    • Choose Python 3.11 (Gen1 for custom runtimes, Gen2 for performance).
  3. Google Artifact Registry:

    • Package code and dependencies in a container image.
    • Push image to Artifact Registry.
    • Update deployment configuration with image reference.

Additional Considerations:

  • Manage dependencies with pip and requirements.txt.
  • Use environment variables for sensitive information.
  • Update Cloud Scheduler job (if used).
  • Implement monitoring and logging.

Former Community Member
Not applicable

I was able to finally make it work by some hit and trial an modifying the code provided in the GAE documentation.

I would just recommend that the documentation is modified for Python 3.11.