betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

09 July 2008

Zope Incremental Backup Script

What I use now
 

With your Zope installation comes the repozo.py script, that allows you to do incremental backups of the ZODB (the Data.fs file). Around that script most people build a shell script and run it through a cron job. Since I just did a new installation (yeah, that's rare for me), I brushed up what I use so far. I'm now automatically keeping 2 generations of backups, whenever a "generation switch" is done, all the moving, deleting etc. is done by the script. The resulting main folder I rsync to a remote machine. Here comes the script...


In fact there are some parts of the shell script that could be done cleaner (e.g. my argument parsing suxx). But the script works and requires little to no work. Setup is by manually adjusting some paths in the script, for a solution that you want to run unchanged on many hosts, you'd likely want to do that with setup files or command line parameters.

Anyway here is what I have now:

#!/bin/sh

# settings:
# (directories without ending slash "/")
ZOPE_HOME="/usr/local/lib/zope29"
INSTANCE_HOME="/var/zope/instancename"
BACKUP_TO="/otherdisk/path/to/zopebackup"

SOFTWARE_HOME="$ZOPE_HOME/lib/python"
DATA="$INSTANCE_HOME/var/Data.fs"
export PYTHONPATH="$PYTHONPATH:$SOFTWARE_HOME"

# determine if full or incremental from command line argument
TYPE="incremental"
if [ $# -eq 1 ]; then
    if [ $1 == "-f" ]; then
        TYPE="full"
    fi
fi

if [ $TYPE == "full" ]; then
    echo "*** Full backup ..."
    mkdir -p $BACKUP_TO
    rm -r $BACKUP_TO/old
    mv $BACKUP_TO/current $BACKUP_TO/old
    mkdir $BACKUP_TO/current
    $ZOPE_HOME/bin/repozo.py -B -F -v -r $BACKUP_TO/current -f $DATA
else
    echo "*** Incremental backup ..."
    mkdir -p $BACKUP_TO/current
    $ZOPE_HOME/bin/repozo.py -B -v -r $BACKUP_TO/current -f $DATA
fi

As the script is based on various pieces floating around on the net, feel free to copy, improve and share again!

My setup:

When you "pack" your Data.fs, repozo.py will start with a full backup again, but the "remaining" files from the previous incremental backups won't be cleaned up. They will be taken care of in the next "generation switch", so I don't really care.

Posted by betabug at 14:13 | Comments (3) | Trackbacks (0)
ch athens
Life in Athens (Greece) for a foreigner from the other side of the mountains. And with an interest in digital life and the feeling of change in a big city. Multilingual English - German - Greek.
Main blog page
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< What to do in Athens when it's hot | Main | Epidaurus >>
Comments
Re: Zope Incremental Backup Script

Hey, nice recipe! I've been using repozo.py for a while now, but didn't know about the incremental option (i should read more carefully about such things).

Thnx for both the recipe and the script sample!

Posted by: Wu at July 09,2008 16:42
Re: Zope Incremental Backup Script

Two questions:
1. How to do with mount points?
2. How to recover a generated backup? Must be done with repozo.py?

Thanks!

Posted by: Julian at February 14,2009 03:28
Re: Zope Incremental Backup Script

Hi Julian!

1. No idea, I don't use mount points myself.
2. Yes, recovery is done via repozo.py too.

Posted by: betabug at February 14,2009 17:52
Trackbacks
You can trackback to: http://betabug.ch/blogs/ch-athens/860/tbping
There are no trackbacks.
Leave a comment