Staging/live setup

In most Aegir CMS setups it is desirable that content is shown on the site only when it is approved, and that changes in content also require approval. The staging/live concept handles this.

Overview

In staging/live you have two Midgard databases, either running on the same system or on separate computers.

  • Staging database — where content is created and tested
  • Live database — where approved content is published

When content is approved it is replicated to the live database using Midgard's repligard utility. Repligard itself doesn't know anything about checking approvals, so some helper scripts are needed.

The aegir-dirs package provides these scripts:

downgrade_unapproved.pl
Called by the staging_to_live script. Goes through the Midgard database and determines which objects are approved and which are not. Sets the "updated" field to NULL for unapproved objects so repligard skips them. See also: http://www.hklc.com/midgard_manual/downgrade_unapproved.pl
repligard_staging_to_live.sh
Runs the full staging-to-live transfer: downgrade unapproved content, export updated objects from staging, import to live database. See: http://www.hklc.com/midgard_manual/topic_73

These scripts assume they're located in /var/nadmin/bin with configuration files from the aegir-dirs package in /var/nadmin/etc.

Automating replication

Add repligard_staging_to_live.sh to cron. Typical usage: run hourly.

To make the Aegir CMS "Publish" button trigger near-instant replication, add this to cron to run every minute:

if [ -r "/tmp/runreplication" ]
  then
    /var/nadmin/bin/repligard_staging_to_live.sh > /dev/null
    rm /tmp/runreplication
fi

More information about replication: Midgard Manual — Repligard