You are not logged in Log in Join
You are here: Home » Members » fritz » Automatically compress Data.fs using cron

Log in
Name

Password

 

Automatically compress Data.fs using cron

Introduction

Greetings!
I have tested this with ZEO 1.0b4
So I will assume it will also work for those running standalone Zope Servers.

Purpose

To automatically compress Data.fs using cron.

- Backup Data.fs before packing.
- Pack Data.fs
- Check for file existence.

Assumptions

  • Your server is secured/ hardened. We don't want anyone else controlling cron.
  • You know a little linux shell scripting.

Procedure

Step 1

For better security:
Create a new file: auth.conf
This will contain your authentication information.
This is so that we can isolate the auth info from the script.

You can optionally put this auth.conf and your compression script in a separate folder.
This is just for ease of use.

Sample auth.conf

ZOPE_AUTH=username:password

That's it! Just one line.
Like I said, this is just to isolate the authentication info from the script.

Step 2

Then here comes the script that will do all the work for you. grins
Note: Some lines are quite long thus, they wrap along the sides.
Just make sure you get them correctly.

#Declarations
#########################################################
ZOPE_PATH="/usr/local/zope"
JOBS_PATH="${ZOPE_PATH}/jobs"
STAMP=`date +%b_%d_%Y`
ZOPE_COMMAND="/usr/local/bin/python ${ZOPE_PATH}/lib/python/ZPublisher/Client.py"
ZOPE_ADDRESS="http://www.foo.com:8080"

#Backup Data.fs before packing
#########################################################
cp ${ZOPE_PATH}/var/test.file ${ZOPE_PATH}/var/Data_${STAMP}.fs_bak

#Authentication Path
#########################################################
. ${JOBS_PATH}/auth.conf

#Pack Database
#########################################################
${ZOPE_COMMAND} -u ${ZOPE_AUTH} ${ZOPE_ADDRESS}/Control_Panel/manage_pack days:float=0

#Notify finished execution
#########################################################
echo ""
echo "Visiting file location..."
echo "Issuing command... ..."
echo ""
ls -la ${ZOPE_PATH}/var/
echo ""
echo "Finished packing new file: Data_${STAMP}.fs_bak"
echo ""

ZOPE_PATH - Where Zope resides.
JOBS_PATH - This is optional. Where you will place your compression script and auth.conf file.
STAMP - This is the time stamp that will be used in the backup file.
Current setup: %b - locale's abbreviated month name (Jan..Dec)
%d - day of month (01..31)
%Y - year (1970...)
ZOPE_COMMAND - This is the command for accessing your Data.fs
ZOPE_ADDRESS - This is your server location. Perhaps you can use "http://localhost:port". I didn't test it though.

Download Sample Script

Click here to download

Summary

This is a simple script that will backup Data.fs first then pack it.
This will give you a previous backup that you can revert to in case you need to.

Acknowledgements

Steve Spicklemire ([email protected])
- For sharing his time and sample scripts.
Bakhtiar A. Hamid ([email protected])
- For sharing his own script.