Create your vms or clone exiting one, give different IP and have it launched.
We use pihole-master (ip xxx.15) that was our existing one that we renamed to be -master. we cloned it and gave the cone the ip xxx.14 and renamed it to pihole-slave. Now we migrate the slave to our second machine if we are operating in a cluster. this way we always have 2 instances on 2 different physical machines.
Next we reconfigure and reset our cloned pihole slave. connect to the shell of the slave pihole and enter: pihole -r
that launches reconfiguring mode, select 2nd options wich will reset to default settings.
Also check if both instances are running the latest version of pihole, if not upgrade with: pihole -up
Go through the system settings of both piholes in the webinterface and make sure they match. compare each setting from master to slave. Once they are 1:1 the same, go back to your shell and upgrade / install the prerequisite packages on both instances:
apt update && apt install sqlite3 sudo git cron rsync ssh
after that is done lets check out the sync repo:
remove sudo rsync permission barriers ON BOTH INSTANCES:
sudo EDITOR=nano visudo
there comment out the sudo line and add this so it looks like:
#%sudo ALL=(ALL:ALL) ALL %sudo ALL=(ALL:ALL) NOPASSWD:ALL
reboot the both server with sudo reboot
on primary pihole launch this command to check everything is ready for sync instacnes:
export GS_INSTALL=primary && curl -sSL https://gravity.vmstan.com | bash
now go to the second instance and check and configure it for sync with this:
export GS_INSTALL=secondary && curl -sSL https://gravity.vmstan.com | bash
now a setup wizzard in the command line starts and ask you about your config
Great now our slave instance can compare, pull and sync from our master pihole!
FIrst we want to just compare our master and slave instance:
This will get you something like this:
So we can see that as our new slave is not configured we have several differences within the instances. We can resolve these with a pull:
Great, now our slave server has the same state as our master main pihole!
Now lets automate the sync of the servers:
It will ask you some questions I setted it up like this:
Now we check the cronjob and edit it with:
change the first line from "smart" to "pull" if you are like me and only use the primary pihole server. So the cronjob looks now like:
*/15 * * * * /bin/bash /home/schnubbi/gravity-sync/gravity-sync.sh pull > /home/schnubbi/gravity-sync/gravity-sync.cron 0 3 * * * /bin/bash /home/schnubbi/gravity-sync/gravity-sync.sh backup >/dev/null 2>&1