{"id":790,"date":"2024-01-22T14:16:38","date_gmt":"2024-01-22T13:16:38","guid":{"rendered":"https:\/\/www.homeserver.lu\/?p=790"},"modified":"2024-01-22T14:16:38","modified_gmt":"2024-01-22T13:16:38","slug":"synchronise-two-pi-hole-servers","status":"publish","type":"post","link":"https:\/\/www.homeserver.lu\/?p=790","title":{"rendered":"Synchronise two Pi-hole servers"},"content":{"rendered":"\n<p>If you run more than one <a href=\"https:\/\/pi-hole.net\" target=\"_blank\" rel=\"noreferrer noopener\">Pi-hole<\/a> server in your network, it can be handy to synchronise both instances so that you do not need to add and maintain your local DNS entries and your ad-block lists on two different machines.<\/p>\n\n\n\n<p>Currently you have two possibilities do achieve this: <a href=\"https:\/\/github.com\/mattwebbio\/orbital-sync\" data-type=\"link\" data-id=\"https:\/\/github.com\/mattwebbio\/orbital-sync\" target=\"_blank\" rel=\"noreferrer noopener\">Orbital-sync<\/a> and <a href=\"https:\/\/github.com\/vmstan\/gravity-sync\" target=\"_blank\" rel=\"noreferrer noopener\">Gravity-sync<\/a>.  Orbital-sync uses the admin interfaces to synchronise. Gravity-sync connects both instances via SSH.<\/p>\n\n\n\n<p>To set up gravity-Sync, you have to do the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>As a precaution, backup both instances of Pi-hole using the <em>backup<\/em> function (under <em>Settings<\/em>, <em>Teleporter<\/em> tab) and, if you use a virtualisation environment, take snapshots of both instances.<\/li>\n\n\n\n<li>If the two Pi-hole servers are running in different VLAN&#8217;s, do not forget to set up the corresponding firewall rules (for both directions).<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"953\" height=\"1024\" src=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/01\/FirewallRule-953x1024.png\" alt=\"\" class=\"wp-image-792\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/01\/FirewallRule-953x1024.png 953w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/01\/FirewallRule-279x300.png 279w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/01\/FirewallRule-768x825.png 768w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/01\/FirewallRule-624x671.png 624w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2024\/01\/FirewallRule.png 1284w\" sizes=\"auto, (max-width: 953px) 100vw, 953px\" \/><figcaption class=\"wp-element-caption\">One of the two firewall rules in my Unifi Dream Machine Pro<\/figcaption><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>On both Pi-hole instances: Install Gravity-sync using this command (<a href=\"https:\/\/github.com\/vmstan\/gravity-sync\/wiki\/Installing\" target=\"_blank\" rel=\"noreferrer noopener\">source<\/a>):<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>curl -sSL https:\/\/raw.githubusercontent.com\/vmstan\/gs-install\/main\/gs-install.sh | bash<\/code><\/pre><\/div>\n\n\n\n<p>A wizard will ask you for the connection information (IP, user, password) for the remote host. The configuration will be saved in <em>\/etc\/gravity-sync\/gravity-sync.conf<\/em>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>On both Pi-hole instances: Run a comparison of the local and remote Pi-hole databases using:<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>gravity-sync compare<\/code><\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>On your master Pi-hole instance, push the configuration from your master to the slave instance. Be careful not to push a default or incomplete configuration of a new instance to your running instance.<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>gravity-sync push<\/code><\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>On both Pi-hole instance: To automate synchronisation run the following command:<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>gravity-sync auto<\/code><\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Additionally: to adjust the frequency of updating, run one of the following commands:<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>gravity-sync auto hour\ngravity-sync auto half\ngravity-sync auto quad<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you run more than one Pi-hole server in your network, it can be handy to synchronise both instances so that you do not need to add and maintain your local DNS entries and your ad-block lists on two different machines. Currently you have two possibilities do achieve this: Orbital-sync and Gravity-sync. Orbital-sync uses the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[38],"tags":[],"class_list":["post-790","post","type-post","status-publish","format-standard","hentry","category-dns"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=790"}],"version-history":[{"count":12,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/790\/revisions"}],"predecessor-version":[{"id":803,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/790\/revisions\/803"}],"wp:attachment":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}