[Zope] ANN: zupdate.py - synchronize multiple distributed Zopes

Thilo Ernst Thilo.Ernst@dlr.de
Thu, 10 May 2001 15:48:12 +0200


Hello,  fellow Zope users:

as the  number of Zope installations I'm working with showed some growth recently  (besides a production, a development and a
test server I set up an experimental installation from time to time as well) -  I got tired of
manually distributing stuff from the development site to the other ones using Export, then ftp or scp, then Import.

A search on zope.org didn't reveal much prior art, just that a 'Synchronizable Objects' and a 'Synchronization tab'
seem to be planned for future Zope releases. (If someone knows a suitable existing tool nevertheless, please
send me a  note.)  Thus, I decided to write something on my own. Here is the the result:

                      http://www.zope.org/Members/te0006/zupdate.py

zupdate.py is a stand-alone Python (1.52 or higher) script fot updating selected objects on one or more remote
Zope instances from a local 'master' (e.g. development) site.  It works by:
- making the local ('master') Zope instance export the selected objects to a set of .zexp files
- transferring the .zexp files to the remote server(s) via scp (the secure variant of rcp that comes with ssh)
- re-importing the objects to their appropriate locations in the remote Zopes' object  hierarchy
All Zope servers can remain 'live' all the time as the Import/Export actions are invoked via HTTP.
The .zexp files are automatically grouped so scp will be invoked (and will ask for authentication) only once
per remote server. Their collection and transfer is also done using synthetic filenames to avoid name clashes.

zupdate.py expects as a command line argument a task description file containing a set of Python
statements which describe the local and all remote Zope instances  (URL, username/password
for administrator, Zope root  directory in filesystem), and which objects to transfer.
Invoking zupdate.py without  parameters provides detailed information about the structure of the
task description.  A sample task description file is appended to this mail.

zupdate.py was tested on a Linux 2.2 i386 system  (RH 7.1) but should be able to run with minor changes
on any system where Python 1.5.2 (or higher) and scp are available; of course, the remote servers
must have ssh/scp as well.

IMPORTANT NOTE: This script is hardly more than a quick hack. Even though it did work for me, it will
likely have bugs. Every conceivable standard disclaimer applies. You cannot hold me liable for anything.
Use at your own risk.  License: Python-style.


Best regards,

Thilo Ernst


# SAMPLE TASK DESCRIPTION FILE

# no real hostnames & administrator credentials, sorry


# local Zope installation
LZOPE=(
    'localhost:8080', ('adm', 'adm42'),
    '/ZOPE/Zope-2.3.1b2-linux2-x86'
    )

# remote Zope installation, or list thereof
RZOPE= [
      # test site
    ( 'test1.zopecentral.org:8080',  ('Administrator1', 'Secret'),
      'testuser@test1.zopecentral.org:/ZOPE/Zope-2.3.1b2-linux2-x86'),
      # production site
    ( 'www.zopecentral.org:80',      ('Almighty', 'TopSecret'),
      'zopeuser@www.zopecentral.org:/ZOPE/Zope-2.3.1b2-linux2-x86')
    ]

# objects to be updated, optionally with deviating target folders
OBJS= [
        ('/myfolder/obj1', '/yourfolder'), # different folder in target Zope instance
        '/ourfolder/obj2'                           # same folder
    ]