Restoring an older state of arbitrary Zope objects
It is well-known that the Undo functionality of Zope (as as wrapped through Plone UI) usually does not work when other transactions happened in-between. Common use-case: you deleted some content (e.g. a Plone folder or a Plone document) some days ago and you need it back (it's usually the boss messing up company contents and then yelling days later at you to get the content back).
You friendly helper is dm.historical (one of the few Dieter tools I really appreciate).
Here is the blueprint how to recover removed content from a ZODB storage. We assume that we are running some Plone site and want to recover a folder originally located under /plone/myfolder and now it is gone and you want it back.
- Add dm.historical to your buildout (eggs section and re-run buildout)
- Start your instance in debug mode (bin/instance debug) and after loading type the following on the console:
from DateTime import DateTime
from dm.historical import getObjectAt
site = getObjectAt(app.plone, DateTime('2010-08-05 14:00:00')) folder = site['myfolder']
folder.manage_exportObject()
That's it.
Keep in mind that you can not restore object versions older than the timestamp of your last ZODB pack operation. So when you packed one week ago (with the option keeping the revisions of the last seven days) you will not be able to restore revisions older than two weeks.
