• Recovering a ZODB Data.fs file using repozo

last modified January 13, 2010 by ejucovy

Sometimes you need to go back in time and recover lost data, or create a testing database from backups of the production data.

Recovering the database from a particular date

  1. put appropriate libraries onto path
  2. recreate data file for a particular date via repozo

$ cd /path/to/virtualenv; . bin/activate
$ zope/bin/zopectl shell
$ lib/zope/bin/repozo.py --recover --date='yyyy-mm-dd' --output=/path/to/zeo/var/Data.fs --repository=/backup/path/to/repozo

notes: I always use tomorrow's date for yyyy-mm-dd so as to get all of today's changes.

This will create a Data.fs file in the specified location based on the repozo backups living in the specified repozo directory. The date flag is optional... once the PYTHONPATH has been set up you can just type 'repozo.py' to see all of the options that are available.

In a Fassembled build of OpenCore, /path/to/zeo/var/Data.fs = ${build_root}/var/zeo/Data.fs

So e.g. if  your /path/to/virtualenv for the current build is /home/lammy/myopencoresite.com/builds/20091126/opencore/ then you should look for Data.fs in /home/lammy/myopencoresite.com/var/zeo/Data.fs

To recover lost documents:

Sometimes we may need to retrieve individual documents from an older ZODB backup, without actually replacing the entire production database with an older copy. In this case, we can restore from repozo backups from the appropriate date, into a development opencore instance that will not interfere with the production environment. Then you can start the dev instance and take the following steps:

  1. find the lost document on dev in the zmi
  2. use the import/export dialogue to export it to the server as a zexp.
  3. move the document(my-document-id.zexp) from /path/to/dev/zeo/var -> /path/to/live/zope/import
  4. navigate in the zmi to where you want the document to appear
  5. use the import/export dialogue to import it.

Voila! for most objects, should load up just fine.