Random ...
 
December 2017
S M T W T F S
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Tags ...
Links



python+zope++:: Backup/restore zope instance
Posted at 22.Jun,2007 12:44  Comments 0 / Trackbacks 0 / Like this post!
Technorati tag(s):

Here's how we can backup (incrementally or full) a zope instance.

First off, get repozo.py, usually came by default in $SOFTWARE_HOME/bin with zope versions >= 2.8

Then fire up this script daily, hourly, etc; up to your paranoia level :) :

  #/bin/bash
  #backup.sh
  SOFTWARE_HOME=/path/to/your/zope/software/home 
  #e.g /usr/local/zope28/lib/python

  INSTANCE_HOME=/path/to/your/zope/instance/home
  #e.g /usr/local/zopehome

  ZOPE_HOME=/path/to/zope
  # e.g /usr/local/zope28

  REPOHOME=/path/to/backup/dir
  #e.g /home/zope/backup

  export PYTHONPATH=$PYTHONPATH:$SOFTWARE_HOME
  #backup.  default incremental, 
  #unless we've done a pack or it's a new Data.fs
  $ZOPE_HOME/bin/repozo.py -B -f $INSTANCE_HOME/var/Data.fs -r $REPOHOME

chmod 755 backup.sh, and put it in cron.

You'll get something similar to this:

  ~]$ ls -lh backup/
  total 2.8G
  -rw-rw-r--  1 zope zope  188 Jun 22 11:25   2007-06-22-03-13-51.dat
  -rw-rw-r--  1 zope zope 2.8G Jun 22 11:17 2007-06-22-03-13-51.fs
  -rw-rw-r--  1 zope zope 2.1K Jun 22 11:25 2007-06-22-03-25-04.deltafs

To restore, run this at the command line:

  export PYTHONPATH=$PYTHONPATH:/path/to/zope/softwarehome
  /path/to/zope/softwarehome/bin/repozo.y -R -o /path/to/store/recovered/file -r /path/to/your/repo -D yyyy-mm-dd

Here's the full repozo.py help:

  repozo.py -- incremental and full backups of a Data.fs file.

  Usage: /usr/local/zope28/bin/repozo.py [options]
  Where:

    Exactly one of -B or -R must be specified:

    -B / --backup
        Backup current ZODB file.

    -R / --recover
        Restore a ZODB file from a backup.

    -v / --verbose
        Verbose mode.

    -h / --help
        Print this text and exit.

    -r dir
    --repository=dir
        Repository directory containing the backup files.  This argument
        is required.  The directory must already exist.  You should not
        edit the files in this directory, or add your own files to it.

  Options for -B/--backup:
    -f file
    --file=file
        Source Data.fs file.  This argument is required.

    -F / --full
        Force a full backup.  By default, an incremental backup is made
        if possible (e.g., if a pack has occurred since the last
        incremental backup, a full backup is necessary).

    -Q / --quick
        Verify via md5 checksum only the last incremental written.    This
        significantly reduces the disk i/o at the (theoretical) cost of
        inconsistency.  This is a probabilistic way of determining  whether
        a full backup is necessary.

    -z / --gzip
        Compress with gzip the backup files.  Uses the default zlib
        compression level.  By default, gzip compression is not used.

  Options for -R/--recover:
    -D str
    --date=str
        Recover state as of this date.  Specify UTC (not local) time.
            yyyy-mm-dd[-hh[-mm[-ss]]]
        By default, current time is used.

    -o filename
    --output=filename
        Write recovered ZODB to given file.  By default, the file is
        written to stdout.

  --repository is required

Now, we have backups, just in case ...


Bookmark and Share

Is this entry helpful? Comments/Donate/Click some google ads.  
Trackback is http://myzope.kedai.com.my/blogs/kedai/138/tbping 

Comments
Post a comment