Chez
Chez

Reputation: 989

Recover image files accidentally deleted from Google Cloud bucket

Is it possible to recover lost files in Google Cloud?

Only deleted this evening by a quirk of fate, I ran a task that should not have been run.

All the data is image data, so before I write some code to stub the lost images with a template image I'd like to know if it is at all possible to recover them?

Upvotes: 1

Views: 7731

Answers (1)

Tuxdude
Tuxdude

Reputation: 49513

Google Cloud Storage provides Object Versioning which lets you do exactly what you're asking for - be able to recover previous versions of objects (i.e. files) including deleted ones similar to a version control system.

However, you need to turn on Object versioning for a GCS bucket before you can go over the different versions of objects within the bucket. Without that it is not possible to recover any files deleted from your GCS bucket.

How Object Versioning works

Cloud Storage allows you to enable Object Versioning at the bucket level. Once enabled, a history of modifications (overwrite / delete) of objects is kept for all objects in the bucket. You can list archived versions of an object, restore an object to an older state, or permanently delete a version, as needed.

All objects have generation numbers that allow you to perform safe read-modify-write updates and conditional operations on them. Note that there is no guarantee of ordering between generations.

When an object is overwritten or deleted in a bucket which has versioning enabled, a copy of the object is automatically saved with generation properties that identify it. You can turn versioning on or off for a bucket at any time. Turning versioning off leaves existing object versions in place, and simply causes the bucket to stop accumulating new object versions. In this case, if you upload to an existing object, the current version is overwritten instead of creating a new version.

Upvotes: 2

Related Questions