What is better than a Pi-hole blocking ads via DNS on your network? That's right, Two Pi-hole! But if you have more than one Pi-hole (PH) in your network you'll want a simple way to keep the list configurations identical between the two. I've recently been toiling away at a script to do exactly this, and what started as a few lines lines of bash was shared with some friends, and has grown into what I now call Gravity Sync -- which I'd now like to share with you all for your feedback.
https://github.com/vmstan/gravity-sync
At it's core, Gravity Sync is maybe a handful of core bash commands, that uses rsync to reach out to a remote host, copy the running gravity.db
file that contains the Pi-hole blocklist, and then replaces the copy on the local system. What Gravity Sync provides is an easy way to keep this happening in the background. Ideally you set it and forget it. In the long term, it would be awesome if the Pi-hole team made this entire script unncessary.
Gravity Sync will not overwrite device specific settings such as local network configuration, admin/API passwords/keys, local hostfiles, upstream DNS resolvers, etc. It will also not keep DHCP settings or device leases synchronized.
Gravity Sync requires Pi-hole 5.0 or higher.
You will need to designate one Pi-Hole as primary and one as secondary. This is where you'll make all your configuration changes through the Web UI, doing things such as; manual whitelisting, adding blocklists, device/group management, and other list settings. Gravity Sync will pull the configuration of the primary PH to the secondary. It will also bring over the downloaded blocklist files after a pihole -g
update on the primary, so you do not need to reach out to all your blocklist hosts for updates after syncing.
The designation of primary and secondary is purely at your discretion and depends on your desired use case.
Additionally, some things to consider:
- Gravity Sync is regularly tested during development with Ubuntu and Raspberry Pi OS (previously, Raspbian). As Gravity Sync is just an (admittedly) long bash script, it will likely work on other Linux distributions that have the
bash
shell installed. But please file an Issue if you're unable to run it on another platform. - Gravity Sync has not been tested with Docker container deployments of Pi-hole, and is not expected to work there without major modifications. You will need Pi-hole setup with a "traditional" install directly in the base operating system.
I would encourage you to read through the documentation on the GitHub site before deployment. The actual install and configuration is fairly simple. I've worked to build in all of the functions necessary to deploy and operate Gravity Sync with as little work by the end user as possible.
I look forward to any feedback you might have, and would encourage you to file any Issues on GitHub.
Thanks!