From 32c77c1ff99a2e719729a6b24b55b2aea5170c24 Mon Sep 17 00:00:00 2001 From: Radar231 Date: Thu, 4 Nov 2021 09:57:51 -0400 Subject: [PATCH] extended to be able to sync remotely via ssh, or locally via instance shared storage --- README.md | 9 +++++++- pihole-dns-sync_local.sh | 21 +++++++++++++++++++ ...-dns-sync.sh => pihole-dns-sync_via-ssh.sh | 0 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 pihole-dns-sync_local.sh rename pihole-dns-sync.sh => pihole-dns-sync_via-ssh.sh (100%) diff --git a/README.md b/README.md index 2156c86..6765365 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ ## Introduction -This repo contains a simple script used to sync the dns and cname configuration +This repo contains simple scripts used to sync the dns and cname configuration files from a primary pihole server to a secondary pihole server. +* pihole-dns-sync_via-ssh.sh + * runs on the secondary pihole and pulls from the primary via ssh + +* pihole-dns-sync_local.sh + * runs on a host mounting common storage between the two pihole instances (ie, for k8s deployment) + * copies the files from the primary pihole instance storage to the secondary pihole instance storage + diff --git a/pihole-dns-sync_local.sh b/pihole-dns-sync_local.sh new file mode 100755 index 0000000..37d5053 --- /dev/null +++ b/pihole-dns-sync_local.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# base directory path +basepath='/mnt/k8s-storage/pihole' +srcdir='pihole-1' +dstdir='pihole-2' +# declare and populate indexed sync array +syncarray=('etc-pihole/custom.list' 'etc-dnsmasq-d/05-pihole-custom-cname.conf') + +curdate=$(date +%Y%m%d-%H%M%S) + +echo "pihole dns sync run: ${curdate}" + +for i in "${syncarray[@]}" +do + echo "syncing $i" + echo cp ${basepath}/${srcdir}/${i} ${basepath}/${dstdir}/${i} +done + +echo "pihole dns sync run completed" + diff --git a/pihole-dns-sync.sh b/pihole-dns-sync_via-ssh.sh similarity index 100% rename from pihole-dns-sync.sh rename to pihole-dns-sync_via-ssh.sh