Pi Flavored Pi! Syncing two PiHole Instances
Imagine you’re in a world where every Pi is a flavor sensation, where Raspberry Pi isn’t just a computer—it’s a culinary adventure. Picture yourself with not one, but two delectable slices of Pi, each bursting with its own unique flavor profile. That’s right, we’re talking Pi flavored Pi.
Now, you might be scratching your head and wondering, “How on earth do we achieve such a deliciously flavorful Pi?” Well, fear not, because the answer is as easy as Pi itself. Allow me to introduce you to Gravity Sync—a magical script that turns your PiHole instances into a symphony of synchronized sweetness.
So what is Gravity Sync? Gravity Sync is a script that allows you to have two PiHole instances without worrying about manually copying your settings over. Need to update your blocklist? No longer will you have to do it on both servers! Just update it on one, and let Gravity Sync do the rest. But this can’t be easy, right? Oh its so easy to do, you could say its easy as pi.
Lets get started. To start, make sure you have at least two PiHole servers running (If you still need to create a PiHole server, this is a great guide https://www.youtube.com/watch?v=FnFtWsZ8IP0) All steps for this install can be also found on the official Gravity Sync github repo here: Gravity Sync.
To get started, we are going to make a backup of our configurations to be safe. Login to the PiHole Admin interface for both of your PiHole servers and click on “Settings”.
Once you are in the “Settings” menu, click on “Teleporter” in the top menu and then you can click on “Backup” to make a local backup.
Repeat this process for your other PiHole instance and then we can get started with installing Gravity Sync.
Open a SSH session to both of your PiHole servers (or if you have the ability to do a desktop session, launch terminal). The first command we want to enter is:
curl -sSL https://raw.githubusercontent.com/vmstan/gs-install/main/gs-install.sh | bash
Enter your password when prompted.
Eventually you’ll be asked to enter an IP. This is the IP of the other PiHole server. Enter the IP and hit enter. You’ll then be asked to enter the username of the other PiHole server. Type that in and hit enter. If you haven’t done a SSH between either server before, it may ask you to continue connecting as the fingerprint hasn’t been seen before. Finally, enter the other PiHole’s account password and hit enter.
Repeat these steps on your second instance of PiHole. Once both PiHole’s have had Gravity Sync installed, pick one to be the master PiHole and run the following command on that system:
gravity-sync push
If you are getting asked to enter the password for the other PiHole instance, check out this issue here. I ran into this and doing a sudo rm -rf /etc/gravity-sync followed by running the install again solved my problem. This may be caused by the SSH key not being recognized if you have never SSH’d to your other PiHole instance.
Once the initial sync has finished we can then automate this whole setup. There are four different commands we can run to make the sync happen automatically:
- gravity-sync auto (Default sync, replication should happen in under 5 minutes.)
- gravity-sync auto hour (Hour sync)
- gravity-sync auto half (Half hour sync)
- gravity-sync auto quad (Quarter hour sync)
Since I would like my PiHole’s to be up to date fairly quickly, but also give me some time to fix an issue if I bork a setting on my primary PiHole, I am going to choose gravity-sync auto quad, for syncs every 15 minutes. Run the command of your choosing, wait for it to finish, and you are done!
Welcome to having Pi flavored Pi!
I really feel like I would be able to relate to this, if you maybe gave some background information on how you used to be a chef.