GreenArrow Email Software Documentation

Sync Config

Introduction

This command synchronizes the following configuration from this GreenArrow server to one or more other GreenArrow servers:

  • VirtualMTAs (IP Addresses, Relay Servers, and Routing Rules)
  • Throttle Programs
  • Throttle Templates
  • DKIM keys
  • Incoming Email Domains
  • URL Domains
  • Mail Classes
  • The system default VirtualMTA, Bounce Mailbox, and URL Domain

This is useful for setting up a cluster of GreenArrow servers were these areas of the configuration are managed through the API or UI (instead of the greenarrow.conf configuration file).

Configuration

The remote GreenArrow servers to sync to are configured in:

/var/hvmail/control/opt.sync_to_remote_greenarrow

The format of this file is one destination server per line. Each line contains a hostname, colon, then password to the greenarrow user account.

For example:

sync_target_hostname.example.com:this_is_the_password

These target servers must be configured to allow remote Postgres database access from this server.

See this documentation on how to do this.

Commands

The first argument of this program is the command to perform.

The following commands are supported:

trigger_setup

Setup database triggers so that this service can detect when any configuration has changed.

trigger_remove

Remove the database triggers setup by trigger_setup.

service_setup

Install the /service/sync-config-to-remote-greenarrow service that will automatically run the live_sync command.

service_remove

Remove the service installed by service_setup.

manual_sync

Do one synchronization out to each of the remote servers.

live_sync

Do one synchronization out to each of the remote servers, then enter a polling loop that check each second to see if any configuration has changed and does a new synchronization to each remote server only when the config has changed.

This polling loop runs for a maximum of one hour and then exits. It is intended that you restart the program to run for another one hour. The service created by service_setup automatically does this.

help or --help

Print this help page.

How To Set Up Automatic Synchronization

The server that publishes out its configuration is the “primary server”.

The servers that get the configuration are the “remote servers”.

  1. Install this script as /var/hvmail/bin/hvmail_sync_config_to_remote_greenarrow and chmod 755.

  2. Configure the remote servers to allow remote Postgres database access from this server.

    Perform the steps under “Configure PostgreSQL to Listen for Remote Connections” and “Authorize Remote Client Access.” You do NOT need to perform the steps under “Create the read-only user account.”

  3. Configure the /var/hvmail/control/opt.sync_to_remote_greenarrow file with all of the remote server hostnames and the postgres password for the greenarrow database user on each server. You can find this password in the /var/hvmail/control/db.password file on each server.

  4. Test performing a manual sync by running this command:

    /var/hvmail/bin/hvmail_sync_config_to_remote_greenarrow manual_sync
    

    Fix any errors with accessing the remote servers.

  5. Setup a service on the primary server to automatically publish out config to each remote server when the config changes on the primary server or the list of remote servers changes.

    Run these commands:

    /var/hvmail/bin/hvmail_sync_config_to_remote_greenarrow trigger_setup
    /var/hvmail/bin/hvmail_sync_config_to_remote_greenarrow service_setup
    

  6. Verify that the service is running correctly and that the automatic sync works.

    Monitor the logfile of the service by running this command:

    tail -F /var/hvmail/log/sync-config-to-remote-greenarrow/current | tai64nlocal
    

    (Type Control-C to stop monitoring the logfile.)

    Check on the status of the service by running this command:

    svstat /service/sync-config-to-remote-greenarrow
    

    Make a change on the primary server and verify that it is replicated to all of the remote servers.

How To Remove Automatic Synchronization

  1. Shut down the service.

    Run this command:

    svc -d /service/sync-config-to-remote-greenarrow
    

    Verify it has stopped with this command:

    svstat /service/sync-config-to-remote-greenarrow
    

  2. Remove the service.

    Run these commands:

    /var/hvmail/bin/hvmail_sync_config_to_remote_greenarrow service_remove
    /var/hvmail/bin/hvmail_sync_config_to_remote_greenarrow trigger_remove
    

  3. Delete the /var/hvmail/control/opt.sync_to_remote_greenarrow configuration file.

    Run this command:

    rm /var/hvmail/control/opt.sync_to_remote_greenarrow
    

  4. Reconfigure the remote database servers to not allow Postgres connections from the primary server.

    You will undo what following these instructions did.


Copyright © 2012–2025 GreenArrow Email