Outils personnels
Vous êtes ici : Accueil Blog Packing the ZODB offline
Navigation
 
Actions sur le document

Packing the ZODB offline

Filed Under:

Packing the ZODB offline

While working for a client, I had the need to transfer the Data.fs file from the customer's server to my development machine, but I was not authorized to pack the database.

Due to other commitments I was working at night, so I would have to miss a whole day of work on this project if I waited for someone else to pack the db the next day. The file's size was 14GB so transfering it as it was really was out of the question.

I had a regular user ssh acount, so there were a couple of ways available for me to pack a copy of the ZODB, but the Python interpreter seemed to me to be the easiest path to success:

>>> import time
>>> import ZODB.FileStorage
>>> import ZODB.serialize
>>> storage=ZODB.FileStorage.FileStorage('/home/cguardia/Data.fs.copy')
>>> storage.pack(time.time(),ZODB.serialize.referencesf)

Done! The file shrunk from 14GB to 360MB and the transfer was done in time for me to get some work done that night.

In case anyone wonders about this, the referencesf parameter is part of the storage interface and is required for the pack method, even though apparently FileStorage doesn't use it in any way. If you are curious, referencesf is a function that returns the ids of objets inside a pickle. If you want to know still more, then you've got me. This is as far as I'm willing to go.