Support for "hooks" on white/black/ad-list actions

This is not a bug report, this is a please consider / feature request.

my Goal: Sync the various lists between multiple hosts / pihole instances. Ideally I would like to add a white/black/ad list entry on one host and have it replicated across other hosts.

I understand why moving away from text files and towards a binary database will be worth it. I am really looking forward to being able to put comments next to various whitelist entries!!!

However, this move now makes it very difficult to keep multiple PiHole instances in sync with each other. It’s trivial to sort out conflicts when merging text files, but it’s not as simple when merging conflicts in binary files!

Similarly, It is not reasonable to assume that the multiple pihole instances could share a common database host. That is: if PiHole added support for Postgres or MySQL in addition to the SQLite files it may not be the case that $PiHoleHost1 and $PiHoleHost2 could both access $PiHoleDataBaseHost

The Ask: Please give operators a way receive notifications when a user changes part of the database. It can be as simple as just placing a shell script in /etc/pihole/gravity-hooks.d/ that the PiHole web application will invoke with some environment variables that explain what action the user just took or it can be an API that I’d use to register a call back with.

TL;DR: I am looking forward to the additional capabilities that will come with the SQLite database files for various PiHole lists. I am equally saddened that this will break my current git based techniques to keep my black/white/ad lists synchronized across multiple hosts. I am asking for an API or other mechanism that would allow for notification when the user makes a change to the PiHole databases so that change can be logged, audited, and replicated across other PiHole instances.

I am aware that there are several tools out there that support synchronizing SQLite databases, but they almost always use a Master -> Slave model or otherwise require live network connectivity. I would like to keep my git-based log/audit/sync methods for keeping multiple PiHole instances in sync.

of course, i am open to other ideas about how to best accomplish my goal

Discussion is welcome :).


That bash script looks like it could be made to mostly work. The delete where comment clause makes me nervous, but would probably work well enough for basic needs.

It still does not address my core ask:

notification when user changes something on a list

That bash script is - effectively - a one way merge and does not address the “how does $piHole2 learn about a whitelist entry that a user on $piHole1 added” question that’s at the core of my request.

A similar, but inverted, technique to the delete where clause may be sufficient to generate a list of all the entries that did not originate from the bulk-import process, but still makes for a non-trivial sync process.

1 Like

Indeed after you deleted the bulk import data flagged by the fixed comment you are left with the user entered data.
Then import the new bulk data.

Exported userdata comes back the next time if accepted. Merging that is more difficult because you could have twice the same data. Once in bulk and once in the active database by the user.

Then you need a file (delta) with only the accepted data and use that to remove user made entries that match that.

After that delete and add the bulk data.