I have an S3 bucket that has a bunch of legacy files. I just switched on versioning and am trying to figure out what sort of deletion protection this gives me for the legacy files, compared to new files uploaded since after the switch. Here's some sample code:
import boto
c = boto.connect_s3()
bucket = c.get_bucket('my-bucket')
pfx='myfolder/subfolder/'
i = 0
for k in bucket.list_versions(prefix=pfx):
if type(k) == boto.s3.deletemarker.DeleteMarker:
print "DM %s %s" % (k.name, k.version_id)
else:
s = k.get_contents_as_string()
print "REG %s %s %d" % (k.name, k.version_id, len(s))
the pfx
contains some legacy files, so the first time I ran this I got something like this:
REG myfolder/subfolder/ null 0
REG myfolder/subfolder/f1 null 369
REG myfolder/subfolder/f2 null 427
REG myfolder/subfolder/f3 null 141
I then deleted f2
using the S3Browser
tool. When I reran the code above, i got this:
REG myfolder/subfolder/ null 0
REG myfolder/subfolder/f1 null 369
DM myfolder/subfolder/f2 KPNaxqBeIrCGKUx3tYUsRDwWzKbX06
REG myfolder/subfolder/f2 null 427
REG myfolder/subfolder/f3 null 141
Question is: is there a way of retrieving/undeleting the (only) version of f2
I just deleted?