The first step in running Bucardo is to add two or more databases to the main bucardo database. Once this is done, information on which tables are to be replicated are added, as well as any groupings of tables. Then the syncs are added. Syncs are named replication actions, copying a specific set of tables from one server to another server or group of servers.
Once Bucardo has been set up, triggers begin storing information about which rows were changed in all the tables of interest. For a swap sync (multi-master), the process goes like this
- A change is made to the table and gets recorded in the bucardo_delta table.
- A notice is sent to the main Bucardo daemon, letting it know that the table has changed.
- The daemon notifies the controller for that sync and returns to listening.
- The controller creates a “kid” to handle the replication, or signals an existing one.
- The kid starts a new transaction and disables triggers and rules on the tables in question.
- It then gathers a list of which rows have changed since the last replication, and then compares the two to figure out what should be done.
- If there is a conflict, then either the standard conflict handler, or a custom one, set per table, is run to sort things out.
- Triggers and rules are re-enabled, and the transaction commits.
- If the transaction fails, then any custom exception handlers are run.
- The child signals to the controller that it has finished.