Joshua Fox
Joshua Fox

Reputation: 19655

How can I backup Google Blobstore?

I need to backup my Google Blobstore.

Although Google is asking users to prefer Google Storage, we have been using Blobstore for a long time and need to safeguard the data against accidental deletion, and also would like to create a copy of the data for testing. And even if we wanted to move to Storage, we need some way of moving the data from Blobstore to Storage, and we would also need a backup before such a big step.

We can write the backup code ourselves if we have to, but the documentation says "An application cannot create or modify Blobstore values except through files uploaded by the user."

What is the best way to do this?

Upvotes: 2

Views: 213

Answers (1)

Dan Cornilescu
Dan Cornilescu

Reputation: 39824

As Jeff O'Neill commented, you don't need to create/write Blobstore data to make a backup (in the Blobstore). You can read the data from Blobstore and create the backup copy in Storage.

You can read the Blobstore data like this:

with blobstore.BlobReader(blob_key) as fd:
    blob_data = fd.read()

If your blobs are too big to read in one op, you can check this post for an iterative blobstore chunk read approach (and writing the data to GCS): Google App Engine: How to write large files to Google Cloud Storage

Upvotes: 1

Related Questions