vmstan / gravity-sync

💫 The easy way to synchronize the DNS configuration of two Pi-hole 5.x instances.
https://vmstan.com/gravity-sync/
GNU General Public License v3.0
2.3k stars 131 forks source link

Allow sync between more than 2 PiHoles. #376

Closed pauljrowland closed 3 months ago

pauljrowland commented 1 year ago

Would it be possible to implement this in a way which syncs more than 2 PiHoles?

I understand as it's more than a 2-way sync, a master-slave topology may need to be introduced (i.e. changes made on number 1 are pushed to 2, 3 4,.... etc.).

I am using 2 PiHoles at work using gravity-sync and we have a second site. This will total 4 PiHoles and it would be nice to keep all 4 in sync as opposed to 2 lots of 2.

smithj33 commented 1 year ago

https://www.techaddressed.com/tutorials/gravity-sync-pi-hole-instances/

chupacabra71 commented 1 year ago

Love this project, been using it for a long time now. I would also vote for this feature especially if it was somehow cloud enabled. Aside from wanting a third instance in my home, i am currently maintaining Piholes at my mother and my two sister's houses. would love to be able to make changes in one location and have them all be sync'd. i looked at pihole-cloudsync, but it does not seem to be maintained any longer. also looked at orbital-sync, but the piholes need to be in the same network.

soonic6 commented 1 year ago

https://www.techaddressed.com/tutorials/gravity-sync-pi-hole-instances/

do i understand right, that i have to use gravity-sync auto only on my secondary pihole's and the primary stays "passiv" without any automation?

kodiakastu commented 1 year ago

Those thing only support 2 Piholes. Like OP, I would need to sink multiples piholes to a single one. I was able to sync no1 and no2 together. But no3 always fails to pull no1.

smithj33 commented 1 year ago

Those thing only support 2 Piholes. Like OP, I would need to sink multiples piholes to a single one. I was able to sync no1 and no2 together. But no3 always fails to pull no1.

The instructions I provided above sync multiple. I have 3 instances. #2 syncs with #1. #3 syncs with #1. Been using it without issue.

y8s commented 1 year ago

Quesiton about implementing this after the fact: How do you reconfigure Gravity Sync if it's already installed and you want to add a third pi? is it as simple as gravity-sync disable on the primary install and then gravity-sync pull then gravity-sync auto on the other two configured to point at the primary IP?

smithj33 commented 1 year ago

Quesiton about implementing this after the fact: How do you reconfigure Gravity Sync if it's already installed and you want to add a third pi? is it as simple as gravity-sync disable on the primary install and then gravity-sync pull then gravity-sync auto on the other two configured to point at the primary IP?

Follow the instructions at the link above. On your primary pi, you will need to rerun the gravity sync config and follow the instructions which will make it your primary. Then continue with the tutorial to get your other 2 to sync with the primary.

y8s commented 1 year ago

Quesiton about implementing this after the fact: How do you reconfigure Gravity Sync if it's already installed and you want to add a third pi? is it as simple as gravity-sync disable on the primary install and then gravity-sync pull then gravity-sync auto on the other two configured to point at the primary IP?

Follow the instructions at the link above. On your primary pi, you will need to rerun the gravity sync config and follow the instructions which will make it your primary. Then continue with the tutorial to get your other 2 to sync with the primary.

Looking at the gravity-sync.conf file it looks like it just leaves the host and user blank instead of adding an IP and username:

REMOTE_HOST=''
REMOTE_USER=''

and on the secondary/ies:

REMOTE_HOST='primary ip'
REMOTE_USER='primary username'

The instructions aren't clear on whether or not you need to run gravity-sync auto on the primary as well. It seems to me it wouldn't do anything but throw errors about missing hostname/username.

smithj33 commented 1 year ago

It just needs to be installed on the primary. It's just playing a host role and doesn't connect to anything. I checked my primary config and all the fields are blank. My secondaries have the IP and user like yours. You only run auto on your secondaries or choose a specific schedule, as I did, since Auto is random and I wanted them to all be synced quickly. If you run into issues, it's likely ssh related. Make a change on your primary. Then go to your secondaries and do a Pull to see if the changes synced. Push only works with 2 way sync. Set gavity-sync update as a cron job to keep it updated. Hope that helps.

y8s commented 1 year ago

I did some testing and the primary is "disabled" with the secondaries "auto" and it does what it's supposed to. Auto is fast enough but I might play around with speeding up the secondaries.

How often do you sync?

vmstan commented 3 months ago

Effective July 26, 2024, this project has been retired. Thank you for your use and enthusiasm for a project that began as a few lines of bash in a Slack channel and envolved into something far more complex, and used by many thousands of Pi-hole enthusiasts over the last four years.