Dieses fabfile kann verwendet werden um einen Snapshot zu erstellen.

Python Source icon fabfile.py — Python Source, 1 KB (1167 bytes)


from os.path import join as joinpath

from fabric.api import run, cd, local, lcd
from fabric.operations import get

BUILDOUT_DIR = '/path/to/buildout'

def install_snapshot():
    with cd(BUILDOUT_DIR):
        #Create snapshot on server
        print ('Create snapshot on server')

        #Copy data.fs and related files
        print ('Copy ZODB and related files')
        files = run("ls var/snapshotbackups/ | sort -n | tail -n 3")
        for f in files.split():
            get('var/snapshotbackups/%s'%f, 'var/snapshotbackups')

        #make a tarfile of the blobstorage dirtree, copy it to local and untar it
        print ('Make tarfile of blobstorage and copy it to local buildout')
        with cd('var/blobstoragesnapshots'):
            run('tar -cf blobstorage.0.tar blobstorage.0')
        with lcd('var/blobstoragesnapshots'):
            local('tar -xf blobstorage.0.tar')

        #Install new ZODB/Blobstorage snapshot
        print ('Install new ZODB/Blobstorage snapshot')