Sync multiple Pi-Holes with Orbital Sync
Why multiple Pi-holes and keeping them in sync
For redundancy, I run two Pi-hole instances on two different hardware devices.
Out of the box, making a change on one Pi-hole means logging into the other Pi-hole and making the same change, so the Pi-Hole instances return the same results.
Not an ideal situation, in case something was fat fingered, or just plain forgotten to put the change into the second Pi-hole instance.
The Gravity Sync project has gotten a lot of notice from Pi-Hole users, but seemed a little difficult to set up in a Docker container.
I came across the Orbital Sync project that does the same thing, but, at least IMHO, much easier to set up.
Orbital Sync is designed to rely less on the servers running Pi-hole, but rather acting on the admin interfaces like a user would.
How Orbital Sync works
With Orbital Sync, you designate one Primary Pi-hole, and the other Pi-hole(s) pull the config from the primary Pi-hole.
Note: Changes made on the non-primary Pi-hole will be overwritten when synced from the primary Pi-hole.
Configure and deploy Orbital Sync
The yaml file for Orbital Sync is pretty simple, and I just append this to my existing Pi-hole compose.yaml file.
Sample Orbital Sync yaml file:
version: '3'
services:
orbital-sync:
image: mattwebbio/orbital-sync:1
environment:
PRIMARY_HOST_BASE_URL: 'https://pihole1.example.com'
PRIMARY_HOST_PASSWORD: 'your_password1'
SECONDARY_HOST_1_BASE_URL: 'https://pihole2.example.com'
SECONDARY_HOST_1_PASSWORD: 'your_password2'
SECONDARY_HOST_2_BASE_URL: 'http://192.168.1.3'
SECONDARY_HOST_2_PASSWORD: 'your_password3'
SECONDARY_HOST_3_BASE_URL: 'http://server:8080'
SECONDARY_HOST_3_PASSWORD: 'your_password4'
SECONDARY_HOST_3_PATH: '/apps/pi-hole'
INTERVAL_MINUTES: 30
Results
After configuring and deploying Orbital Sync, looked at the logs to verify it works:
10/1/2023, 11:13:06 AM: ➡️ Signing in to http://192.168.1.6/admin...
10/1/2023, 11:13:06 AM: ✔️ Successfully signed in to http://192.168.1.6/admin!
10/1/2023, 11:13:06 AM: ➡️ Downloading backup from http://192.168.1.6/admin...
10/1/2023, 11:13:06 AM: ✔️ Backup from http://192.168.1.6/admin completed!
10/1/2023, 11:13:06 AM: ➡️ Signing in to http://192.168.1.5/admin...
10/1/2023, 11:13:06 AM: ✔️ Successfully signed in to http://192.168.1.5/admin!
10/1/2023, 11:13:06 AM: ➡️ Uploading backup to http://192.168.1.5/admin...
10/1/2023, 11:13:07 AM: ✔️ Backup uploaded to http://192.168.1.5/admin!
10/1/2023, 11:13:07 AM: Result:
Start importing...<br>
Processed adlist (2 entries)<br>
Processed adlist group assignments (2 entries)<br>
Processed blacklist (exact) (0 entries)<br>
Processed blacklist (regex) (0 entries)<br>
Processed client (0 entries)<br>
Processed client group assignments (0 entries)<br>
Processed local DNS records (2 entries)<br>
Processed black-/whitelist group assignments (9 entries)<br>
Processed group (1 entry)<br>
Processed whitelist (exact) (7 entries)<br>
Processed whitelist (regex) (2 entries)<br>
Done importing
10/1/2023, 11:13:07 AM: ➡️ Updating gravity on http://192.168.1.5/admin...
10/1/2023, 11:13:10 AM: ✔️ Gravity updated on http://192.168.1.5/admin!
10/1/2023, 11:13:10 AM: Result:
data: [i] Neutrino emissions detected...
<------ [✓] Pulling blocklist source list into range
[i] Preparing new gravity database...
<------ [✓] Preparing new gravity database [i] Creating new gravity databases...
<------ [✓] Creating new gravity databases
[i] Using libz compression
[i] Target: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
[i] Status: Pending...
<------ [✓] Status: Retrieval successful
<------ [✓] Parsed 153664 exact domains and 0 ABP-style domains (ignored 1 non-domain entries) Sample of non-domain entries: - "0.0.0.0"
[i] List stayed unchanged
[i] Target: https://big.oisd.nl
[i] Status: Pending...
<------ [✓] Status: No changes detected
<------ [✓] Parsed 0 exact domains and 194743 ABP-style domains (ignored 0 non-domain entries)
[i] Building tree...
<------ [✓] Building tree [i] Swapping databases...
<------ [✓] Swapping databases [✓] The old database remains available
[i] Number of gravity domains: 348407 (348407 unique domains)
[i] Number of exact blacklisted domains: 0
[i] Number of regex blacklist filters: 0
[i] Number of exact whitelisted domains: 29
[i] Number of regex whitelist filters: 3
[i] Cleaning up stray matter...
<------ [✓] Cleaning up stray matter
[✓] FTL is listening on port 53
[✓] UDP (IPv4)
[✓] TCP (IPv4)
[✗] UDP (IPv6)
[✗] TCP (IPv6)
[✓] Pi-hole blocking is enabled
10/1/2023, 11:13:10 AM: ✔️ Success: 1/1 hosts synced.
10/1/2023, 11:13:10 AM: Waiting 30 minutes...
References
Orbital Sync - Github.com / mattwebbio / orbital-sync https://github.com/mattwebbio/orbital-sync
Gravity Sync - Github.com / vmstan / gravity-sync https://github.com/vmstan/gravity-sync