High availability (HA) for Pi-hole (running two Pi-hole's)

Thanks, this worked for me!

I used the following script to handle some - maybe unnecessary - stuff:

#!/bin/bash
#
#

/usr/bin/rsync "$@"
result=$?
(
	if [ $result -eq 0 ]; then
		ssh root@10.0.0.116 "sed -e 's|=10.0.0.2/23|=10.0.0.116/23|;s|IPV6_ADDRESS=xxx|IPV6_ADDRESS=xxx|' -i /etc/pihole/setupVars.conf"
		ssh root@10.0.0.116 "sed -e 's|10.0.0.2|10.0.0.116|;s|2003:e6:xxx|2003:fd:xxx|' -i /etc/pihole/local.list"
		ssh root@10.0.0.116 "pihole restartdns reload ; \
				systemctl restart lighttpd.service ; \
				systemctl restart pihole-FTL.service"
	fi
) >/dev/null 2>/dev/null </dev/null

exit $result

and this is how my lsyncd config looks like:

settings {
	logfile = "/var/log/lsyncd/lsyncd.log",
	statusFile = "/var/log/lsyncd/lsyncd.status",
	statusInterval = 30
}
 
sync {
	default.rsyncssh,
	delete = true,
	source = "/etc/pihole/",
	host = "root@10.0.0.116",
	targetdir = "/etc/pihole/",
	delay = 20,
	rsync = {
		binary = "/root/rsync-with-pihole-restart.sh",
		archive = true,
		whole_file = true,
		_extra = { "--omit-dir-times" }
		},
	filter = {
        filter = {
                '- pihole-FTL.db',
                '- pihole-FTL.db-journal',
                '- localversions',
                '- localbranches'
                }
}

sync {
	default.rsyncssh,
	delete = true,
	source = "/etc/dnsmasq.d/",
	host = "root@10.0.0.116",
	targetdir = "/etc/dnsmasq.d/",
	delay = 20,
	rsync = {
		binary = "/root/rsync-with-pihole-restart.sh",
		archive = true,
		whole_file = true,
		_extra = { "--omit-dir-times" }
		}
}

Cheers,
Bjoern

2 Likes