Synchronise two Pi-hole servers

If you run more than one Pi-hole server in your network, it can be handy to synchronise both instances so that you do not need to add and maintain your local DNS entries and your ad-block lists on two different machines.

Currently you have two possibilities do achieve this: Orbital-sync and Gravity-sync. Orbital-sync uses the admin interfaces to synchronise. Gravity-sync connects both instances via SSH.

To set up gravity-Sync, you have to do the following:

  • As a precaution, backup both instances of Pi-hole using the backup function (under Settings, Teleporter tab) and, if you use a virtualisation environment, take snapshots of both instances.
  • If the two Pi-hole servers are running in different VLAN’s, do not forget to set up the corresponding firewall rules (for both directions).
One of the two firewall rules in my Unifi Dream Machine Pro
  • On both Pi-hole instances: Install Gravity-sync using this command (source):
curl -sSL https://raw.githubusercontent.com/vmstan/gs-install/main/gs-install.sh | bash

A wizard will ask you for the connection information (IP, user, password) for the remote host. The configuration will be saved in /etc/gravity-sync/gravity-sync.conf.

  • On both Pi-hole instances: Run a comparison of the local and remote Pi-hole databases using:
gravity-sync compare
  • On your master Pi-hole instance, push the configuration from your master to the slave instance. Be careful not to push a default or incomplete configuration of a new instance to your running instance.
gravity-sync push
  • On both Pi-hole instance: To automate synchronisation run the following command:
gravity-sync auto
  • Additionally: to adjust the frequency of updating, run one of the following commands:
gravity-sync auto hour
gravity-sync auto half
gravity-sync auto quad

Leave a Reply