简体   繁体   English

Blobstore备份策略Google App Engine Python

[英]Blobstore Backup Strategy Google App Engine Python

I'm looking for a way to backup the blobstore on Google App Engine to recover from accidental deletion. 我正在寻找一种方法来备份Google App Engine上的blobstore,以便从意外删除中恢复。 I'd like to be able to make a backup of the datastore and blobstore at the same time, so that I could recover the entire system. 我希望能够同时备份数据存储区和blobstore,这样我就可以恢复整个系统。

One thing I tried was using Google Cloud Storage for my blobs, and then making backup copies of buckets. 我尝试过的一件事是为我的blob使用Google Cloud Storage,然后制作存储桶的备份副本。 However, if I delete a file in the blobstore viewer (which also deletes it in google cloud storage), and then restore the file from a bucket backup using gsutil, the blobinfo is still lost. 但是,如果我删除blobstore查看器中的文件(也会在谷歌云存储中删除它),然后使用gsutil从存储桶备份还原文件,则blobinfo仍然会丢失。

I believe I would have to store all the file paths (google cloud storage paths) in my datastore, and then during a restore, recreate blob keys for all those files using create_gs_key(). 我相信我必须在我的数据存储区中存储所有文件路径(谷歌云存储路径),然后在还原期间,使用create_gs_key()为所有这些文件重新创建blob键。 Is the info stored in the blobviewer (file name, content type, size, etc) stored in the datastore? 信息存储在blobviewer中(文件名,内容类型,大小等)是否存储在数据存储区中?

Is there anyway to backup / restore blobstore data without regenerating keys? 无论如何备份/恢复blobstore数据而不重新生成密钥?

Take a look at Google Cloud Storage's object versioning feature. 查看Google Cloud Storage的对象版本控制功能。 Enable versioning on a bucket and when you delete an object it gets archived. 在存储桶上启用版本控制,当您删除对象时,它将被存档。 Later you can choose to restore or permanently delete the archived version: 稍后您可以选择恢复或永久删除存档版本:

Create an object: 创建一个对象:

>>> PUT /bucket/obj

<<< HTTP/1.1 200 OK
<<< x-goog-generation: 12345

Then archive it: 然后归档它:

>>> DELETE /bucket/obj

<<< HTTP/1.1 200 OK

Now it is inaccessible: 现在它无法进入:

>>> GET /bucket/obj

<<< HTTP/1.1 404 NOT FOUND

However you can still request the archived version explicitly: 但是,您仍然可以明确请求存档版本:

>>> GET /bucket/obj?generation=12345

<<< HTTP/1.1 200 OK

Until you delete the archived version: 在删除存档版本之前:

>>> DELETE /bucket/obj?generation=12345

<<< HTTP/1.1 200 OK

Of course... this doesn't protect you from accidentally deleting the archived version. 当然......这并不能保护您不会意外删除存档版本。

You could try using the datastoreadmin backup and restore . 您可以尝试使用datastoreadmin备份和还原

It will back up the datastore entities with the blob keys intact. 它将使用blob键完整备份数据存储区实体。 According to the following, you will still need to back up the blobs separately as you are already doing. 根据以下内容,您仍然需要单独备份blob,就像您已经在做的那样。

Note: Although we do back up datastore entity properties of type BlobKey and Blob, we do not back up the related blobs themselves that are stored in Blobstore or Google Cloud Storage. 注意:虽然我们备份BlobKey和Blob类型的数据存储区实体属性,但我们不会备份存储在Blobstore或Google Cloud Storage中的相关blob本身。 Nor do we back up the datastore BlobInfo entities associated with these blobs. 我们也不备份与这些blob关联的数据存储BlobInfo实体。

Note you can also schedule these backups on a regular basis. 请注意,您还可以定期安排这些备份

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM