Pack the Zope database from an external Cronjob on a regular basis
This recipe shows how to create a windows batch file which packs your Zope database on a regular basis without having to store an unencrypted manager's password within the file system.
Please follow these steps within your ZMI:
- create a role entitled, e.g., "packrole" and assign no rights at all
- create a user on the root level, e.g. "dbpacker" and a password, e.g."dbPW", and assign the "packrole" role. This means the user can't do anything at the time being.
- create a python script, e.g. "packdb", then add and adopt the code below.
- go to the script's security tab and clear all checkboxes under "Acquire permission settings?" For now only managers can access this script.
- give the "packrole" role the permissions "Access Contents Information" and "View"
- go to the proxy tab and assign the "Manager" proxy roles. Now ,managers can edit and update the script and the dbpacker can view it, which means it is now possible to pack the DB
- on the OS level create a cronjob or a batch file (see code below for Windows).
This is the Python code for the packdb script. It sends out an e-mail using the Zope mailhost object.
Code for a Windows batch file:
An alternative and even simpler method to call the pack script is to use wget. Get wget here. This example assumes wget.exe to be currently available in your system path.