How to make a massive Zope/Plone undo through the web

published Jan 16, 2012 01:03   by admin ( last modified Jan 16, 2012 01:03 )

 

Summary:

http://localhost:8080/manage_UndoForm?PrincipiaUndoBatchSize:int=660

....where 660 should be replaced with the number of transactions you need to go back. Then click like crazy.

 

I had the need to back a Zope site in time several months, October 2011 to be specific.

I had deleted a page (after its due date) for a Plone course December 2011 and kept one for December 2007. I did not, repeat not, want to enter everything that has changed in the contents of that course in between those two dates again. There are backups for the entire system but they are rotated, and I caught this late.

The course page is a compound content type consisting of sub objects for dates, pricing and other things. The missing course page had resided in a folder hierarchy that had also been deleted. The easiest would therefore be to just back the entire server in time, rather than trying to find specific edits to undo.

The undo page in the ZMI batches undoable transactions in lots of 20. My plan was to revert everything back to October 2011 (working on a copy of course). So, 20 transactions is not enough. I need a mega batch! I know there are command line scripts were I can find the byte offset for the date I am interested in and then use truncate, but haven't done it for ages (ok, once in 2002), and can the effect still be achieved from the ZMI? It will be an append but that's OK.

If you look at the "Earlier transactions" and "Later transactions" links, you can see that the start and end transactions are encoded as cgi parameters. The batch size is in other words, not hard coded.  So, if the url for "Later transactions" on the second page is

http://localhost:8080/manage_UndoForm?first_transaction:int=0&last_transaction:int=20&PrincipiaUndoBatchSize:int=20

 

We can just change those numbers. So I clicked through "Earlier transactions" until I reached October, noted where I were in transaction numbers and did something like this:

 

http://localhost:8080/manage_UndoForm?first_transaction:int=0&last_transaction:int=660&PrincipiaUndoBatchSize:int=20

I got a big page and I did a lot of clicking of check boxes, and hit "Undo" - worked like a charm. I then copied over the oh so precious text to the production server.

"PrincipiaUndoBatchSize" I did not notice until now, it did not seem to overrule the other numbers; I did not change that one.

Hmmm, must go back and try something.... Yup, this works too:

http://localhost:8080/manage_UndoForm?PrincipiaUndoBatchSize:int=660