Gravity sync

Pi-Hole HA

In our Pi-Hole tutorial we set up an ad-blocking on a Raspberry Pi.
In this tutorial we’ll set up a second Pi-Hole server but we’ll link it with the server we set up before. We’ll use Gravity to sync between both. This will create a High Availability Pi-hole server.


2nd Raspberry Pi or server.
Network connection. (or wifi)


First you’ll need to setup the second pihole server like we did in the tutorial.
Once set up, head over to the Web UI and login to the admin panel.

We’ll want to match the settings between both servers, change the settings on out new (secondary) server and disable DHCP.
For gravity to work a password less sudo is required on both servers. This can be done using the ‘visudo’ command and adding a line for the user with the NOPASSWD added to it.


Replace ‘<user name>’ with the name of the user used for the gravity sync software. Reboot both servers to be sure that all settings have been changed.


Now that both pi-hole systems are online we’ll take a look into the syncing of both servers.
We’ll use an online install script that will make it easy for us to install all required tools. It is an open source bash script, so you can look into it’s source code if you don’t trust it.

Primary Pi-Hole

On the primary side the install script will check if the pi-hole server is ready for the HA setup. It’ll check if all dependencies are installed and add a password-less sudo for the current user if it isn’t already there.

Login to your primary Pi-hole via SSH, and run the following command:

export GS_INSTALL=primary && curl -sSL | bash

Secondary Pi-Hole

Now that our primary setup is ready for the sync, we’ll continue on and ready up the secondary server. Just like before we’ll run the install script which will do the same install as on the pimary server, but in this case for secondary implementation. After installation the script will continue on to the configuration of Gravity-Sync.

Login to your secondary Pi-hole via SSH, and run the following command:

export GS_INSTALL=secondary && curl -sSL | bash
Installer Errors

The above installers are designed to work in 95% of use cases. If you have errors when running the installer script that you cannot resolve and feel that you’re getting them in error, you can also install Gravity Sync to the secondary Pi-hole manually, by using Git Clone in the directory that you want to install Gravity Sync.

VMStan – Github
git clone

This is not needed if the automated installer completes successfully.


Now that our secondary Pi-Hole is complety set up we’ll need to create the config file for gravity.

The configuration utility will guide you through the process of:

  • Specifying the IP or DNS name of your primary Pi-hole.
  • Specifying the SSH username to connect to your primary Pi-hole.
  • Configuring your key-pair and applying it to your primary Pi-hole.
  • Additional settings, if you choose to perform an advanced installation, when prompted.

The configuration will be saved as gravity-sync.conf in the same folder as the script. If you need to make adjustments to your settings in the future, you can edit this file or run the configuration tool to generate a new one.

If you are deploying Gravity Sync to a system using Docker containers, Gravity Sync should detect this and prompt for additional configuration.

All that remains is to execute the script that handles the syncing.
Add a cronjob in crontab -e to automate the syncing.

Leave a reply:

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.