Introduction to Repligard

Repligard is Midgard's utility for replicating information between servers. Most frequent use is to synchronize development and production servers. Another use for Repligard is installing packages.

Repligard is a Midgard application that doesn't use mod_midgard or the PHP bindings. However, Repligard relies on usage of the PHP bindings in database manipulation to keep the repligard change information in consistent state.

The base of a regular Midgard installation is an operating system, which can be either GNU/Linux, Solaris, FreeBSD, Mac OS X or some other brand of UNIX. On top of the OS there is the Midgard base library, which handles all communication with Midgard's database server (currently MySQL).

The database stores all information including replication change information.

Each Midgard object is an entry in the database, and also it has an entry in the database's repligard table, used for replication information. The repligard table links id numbers of individual Midgard objects to GUIDs (general universal id) using the realm (table name) and id columns. While ids may wary between Midgard installations, GUIDs remain the same.

The repligard table also contains two timestamps for each entry, changed and updated. The changed timestamp notes the date when the entry was last changed using Midgard's PHP bindings. The updated timestamp is used by Repligard for determined whether to update a record for the database.

When exporting Midgard objects, Repligard checks if a changed field is greater than the updated field, the object is replicated to the other database. During import phase it does reverse comparision.

If an object was deleted from the source database, it should be also deleted from the target database. To enable this, we have an action field in the repligard table. It either contains 'create', 'update' or 'delete' value depending on which action was last used for the object.

Repligard table will keep information also about objects that have been deleted, so that it will be able to link the GUIDs to correct states of objects during export phase.