Skip to content

Instantly share code, notes, and snippets.

@iceman73
Forked from besmirzanaj/technitium-sync.sh
Last active August 25, 2025 20:08
Show Gist options
  • Select an option

  • Save iceman73/7e9e412d13331825611a582be5ef0b27 to your computer and use it in GitHub Desktop.

Select an option

Save iceman73/7e9e412d13331825611a582be5ef0b27 to your computer and use it in GitHub Desktop.

Revisions

  1. iceman73 revised this gist Aug 25, 2025. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions technitium-sync.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,9 @@
    # This is a very raw script to backup configs (no logs and no stats) from a technitium server
    # to another
    #
    # 20250814 Stocker Modify to Set DHCP Delay Time to 2000MS rather than disable DHCP Scope
    ## 20250814 Stocker Modify to Set DHCP Delay Time to 2000MS rather than disable DHCP Scope
    ## 20250815 Stocker modify DNS Server Internal IP bind
    ###########################################################################################
    # first create two tokens: one on the source server and another one on the destination one
    # fill out the vars below
    # create a cronjob with this script on the destinaton host
    @@ -48,8 +50,11 @@ if [[ -f "$backup_file" ]]; then
    sleep 10

    # set dnsServerDomain on destination server
    echo "Updating DNS server Domain in destination server"
    curl -X POST "http://$dst_dns_server:5380/api/settings/set?token=$dst_dns_token&dnsServerDomain=$dst_dns_serverdomain"
    echo "Updating DNS server Domain and IP in destination server"
    #curl -k -X POST "https://$dst_dns_server:53443/api/settings/set?token=$dst_dns_token&dnsServerDomain=$dst_dns_serverdomain&dnsServerLocalEndPoints=dst_dns_server
    curl -k -X POST "https://$dst_dns_server:53443/api/settings/set?token=$dst_dns_token&dnsServerDomain=$dst_dns_serverdomain&dnsServerLocalEndPoints=$dst_dns_server"



    # disable DHCP on the destination server
    #echo "disabling DHCP in destination server"
  2. iceman73 revised this gist Aug 14, 2025. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions technitium-sync.sh
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@
    # This is a very raw script to backup configs (no logs and no stats) from a technitium server
    # to another
    #
    # 20250814 Stocker Modify to Set DHCP Delay Time to 2000MS rather than disable DHCP Scope
    # first create two tokens: one on the source server and another one on the destination one
    # fill out the vars below
    # create a cronjob with this script on the destinaton host
    @@ -51,8 +52,11 @@ if [[ -f "$backup_file" ]]; then
    curl -X POST "http://$dst_dns_server:5380/api/settings/set?token=$dst_dns_token&dnsServerDomain=$dst_dns_serverdomain"

    # disable DHCP on the destination server
    echo "disabling DHCP in destination server"
    curl -X POST "http://$dst_dns_server:5380/api/dhcp/scopes/disable?token=$dst_dns_token&name=$dhcp_scope_name"
    #echo "disabling DHCP in destination server"
    #curl -X POST "http://$dst_dns_server:5380/api/dhcp/scopes/disable?token=$dst_dns_token&name=$dhcp_scope_name"
    # Set DHCP Response to really high on backup
    echo "Updating DHCP Offer Delay"
    curl -X POST "http://$dst_dns_server:5380/api/dhcp/scopes/set?token=$dst_dns_token&name=$dhcp_scope_name&offerDelayTime=2000"

    # cleanup
    echo "Cleaning up temporary files"
  3. @besmirzanaj besmirzanaj revised this gist Aug 13, 2025. No changes.
  4. @besmirzanaj besmirzanaj revised this gist Dec 12, 2024. 1 changed file with 20 additions and 15 deletions.
    35 changes: 20 additions & 15 deletions technitium-sync.sh
    Original file line number Diff line number Diff line change
    @@ -18,10 +18,12 @@ src_dns_serverdomain='fqdn.of.source.server'
    dst_dns_serverdomain='fqdn.of.dest.server'
    src_dns_token='SOURCE_TECHNITIUM_TOKEN_HERE'
    dst_dns_token='DEST_TECHNITIUM_TOKEN_HERE'
    backup_file="technitium-backup.zip"
    backup_file="/tmp/technitium-backup.zip"
    # update the dhcp scope as per your local settings
    dhcp_scope_name="local-home"

    # Ensure required tools are installed
    command -v curl >/dev/null 2>&1 || { echo "curl is not installed. Aborting." >&2; exit 1; }

    # Check the primary server's health before running the script
    echo "Checking primary Technitium server status"
    @@ -36,21 +38,24 @@ else
    fi

    # restore_backup
    echo "Restoring the backup on $HOSTNAME"
    curl -s --form file="@$backup_file" "http://$dst_dns_server:5380/api/settings/restore?token=$dst_dns_token&blockLists=true&logs=true&scopes=true&stats=true&apps=true&zones=true&allowedZones=true&blockedZones=true&dnsSettings=true&logSettings=true&deleteExistingFiles=true&authConfig=true" --output /dev/null
    if [[ -f "$backup_file" ]]; then
    echo "Restoring the backup on $HOSTNAME"
    curl -s --form file="@$backup_file" "http://$dst_dns_server:5380/api/settings/restore?token=$dst_dns_token&blockLists=true&logs=true&scopes=true&stats=true&apps=true&zones=true&allowedZones=true&blockedZones=true&dnsSettings=true&logSettings=true&deleteExistingFiles=true&authConfig=true" --output /dev/null

    # wait for server to come back
    echo "Waiting for 10 seconds for the destination server to start up"
    sleep 10
    # wait for server to come back
    echo "Waiting for 10 seconds for the destination server to start up"
    sleep 10

    # set dnsServerDomain on destination server
    echo "Updating DNS server Domain in destination server"
    curl -X POST "http://$dst_dns_server:5380/api/settings/set?token=$dst_dns_token&dnsServerDomain=$dst_dns_serverdomain"
    # set dnsServerDomain on destination server
    echo "Updating DNS server Domain in destination server"
    curl -X POST "http://$dst_dns_server:5380/api/settings/set?token=$dst_dns_token&dnsServerDomain=$dst_dns_serverdomain"

    # disable DHCP on the destination server
    echo "disabling DHCP in destination server"
    curl -X POST "http://$dst_dns_server:5380/api/dhcp/scopes/disable?token=$dst_dns_token&name=$dhcp_scope_name"
    # disable DHCP on the destination server
    echo "disabling DHCP in destination server"
    curl -X POST "http://$dst_dns_server:5380/api/dhcp/scopes/disable?token=$dst_dns_token&name=$dhcp_scope_name"

    # cleanup
    echo "Cleaning up temporary files"
    rm -rf $backup_file
    # cleanup
    echo "Cleaning up temporary files"
    rm -rf $backup_file
    fi

  5. @besmirzanaj besmirzanaj revised this gist Jul 1, 2024. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion technitium-sync.sh
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,8 @@ dst_dns_serverdomain='fqdn.of.dest.server'
    src_dns_token='SOURCE_TECHNITIUM_TOKEN_HERE'
    dst_dns_token='DEST_TECHNITIUM_TOKEN_HERE'
    backup_file="technitium-backup.zip"
    # update the dhcp scope as per your local settings
    dhcp_scope_name="local-home"


    # Check the primary server's health before running the script
    @@ -47,7 +49,7 @@ curl -X POST "http://$dst_dns_server:5380/api/settings/set?token=$dst_dns_token&

    # disable DHCP on the destination server
    echo "disabling DHCP in destination server"
    curl -X POST "http://$dst_dns_server:5380/api/dhcp/scopes/disable?token=$dst_dns_token&name=local-home"
    curl -X POST "http://$dst_dns_server:5380/api/dhcp/scopes/disable?token=$dst_dns_token&name=$dhcp_scope_name"

    # cleanup
    echo "Cleaning up temporary files"
  6. @besmirzanaj besmirzanaj revised this gist Apr 12, 2024. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions technitium-sync.sh
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,12 @@
    #!/bin/bash

    # this is a very raw script to backup configs (no logs and no stats) from a technitium server
    # Author: Besmir Zanaj, 2024
    # This is a very raw script to backup configs (no logs and no stats) from a technitium server
    # to another
    #
    # first create two tokens: one on the source server and another one on the destination one
    # fill out the vars below
    # create a cronjob with this script
    # create a cronjob with this script on the destinaton host
    # eg:
    # 30 */6 * * * /path-to/technitium-sync.sh

  7. @besmirzanaj besmirzanaj revised this gist Apr 12, 2024. 1 changed file with 19 additions and 3 deletions.
    22 changes: 19 additions & 3 deletions technitium-sync.sh
    Original file line number Diff line number Diff line change
    @@ -19,19 +19,35 @@ src_dns_token='SOURCE_TECHNITIUM_TOKEN_HERE'
    dst_dns_token='DEST_TECHNITIUM_TOKEN_HERE'
    backup_file="technitium-backup.zip"

    # get_backup

    curl -s "http://$src_dns_server:5380/api/settings/backup?token=$src_dns_token&blockLists=true&logs=false&scopes=true&stats=false&zones=true&allowedZones=true&blockedZones=true&dnsSettings=true&logSettings=true&authConfig=true&apps=true" -o $backup_file
    # Check the primary server's health before running the script
    echo "Checking primary Technitium server status"
    status_code=$(curl --write-out %{http_code} --silent --output /dev/null http://$src_dns_server:5380)

    # restore_backup
    if [[ "$status_code" -ne 200 ]] ; then
    echo "Primary DNS server is not available. Skipping backup"
    exit 1
    else
    echo "Getting the backup archive from the primary server"
    curl -s "http://$src_dns_server:5380/api/settings/backup?token=$src_dns_token&blockLists=true&logs=false&scopes=true&stats=false&zones=true&allowedZones=true&blockedZones=true&dnsSettings=true&logSettings=true&authConfig=true&apps=true" -o $backup_file
    fi

    # restore_backup
    echo "Restoring the backup on $HOSTNAME"
    curl -s --form file="@$backup_file" "http://$dst_dns_server:5380/api/settings/restore?token=$dst_dns_token&blockLists=true&logs=true&scopes=true&stats=true&apps=true&zones=true&allowedZones=true&blockedZones=true&dnsSettings=true&logSettings=true&deleteExistingFiles=true&authConfig=true" --output /dev/null

    # wait for server to come back
    echo "Waiting for 10 seconds for the destination server to start up"
    sleep 10

    # set dnsServerDomain on destination server
    echo "Updating DNS server Domain in destination server"
    curl -X POST "http://$dst_dns_server:5380/api/settings/set?token=$dst_dns_token&dnsServerDomain=$dst_dns_serverdomain"

    # disable DHCP on the destination server
    echo "disabling DHCP in destination server"
    curl -X POST "http://$dst_dns_server:5380/api/dhcp/scopes/disable?token=$dst_dns_token&name=local-home"

    # cleanup
    echo "Cleaning up temporary files"
    rm -rf $backup_file
  8. @besmirzanaj besmirzanaj revised this gist Apr 2, 2024. 1 changed file with 3 additions and 8 deletions.
    11 changes: 3 additions & 8 deletions technitium-sync.sh
    Original file line number Diff line number Diff line change
    @@ -25,15 +25,10 @@ curl -s "http://$src_dns_server:5380/api/settings/backup?token=$src_dns_token&bl

    # restore_backup

    reply=$(curl -s --form file="@$backup_file" "http://$dst_dns_server:5380/api/settings/restore?token=$dst_dns_token&blockLists=true&logs=true&scopes=true&stats=true&apps=true&zones=true&allowedZones=true&blockedZones=true&dnsSettings=true&logSettings=true&deleteExistingFiles=true&authConfig=true")
    curl -s --form file="@$backup_file" "http://$dst_dns_server:5380/api/settings/restore?token=$dst_dns_token&blockLists=true&logs=true&scopes=true&stats=true&apps=true&zones=true&allowedZones=true&blockedZones=true&dnsSettings=true&logSettings=true&deleteExistingFiles=true&authConfig=true" --output /dev/null

    # echo $reply | jq .status

    # wait for serve rto come back
    until curl --output /dev/null --silent --head --fail http://$dst_dns_server:5380; do
    printf '.'
    sleep 5
    done
    # wait for server to come back
    sleep 10

    # set dnsServerDomain on destination server
    curl -X POST "http://$dst_dns_server:5380/api/settings/set?token=$dst_dns_token&dnsServerDomain=$dst_dns_serverdomain"
  9. @besmirzanaj besmirzanaj created this gist Apr 2, 2024.
    42 changes: 42 additions & 0 deletions technitium-sync.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    #!/bin/bash

    # this is a very raw script to backup configs (no logs and no stats) from a technitium server
    # to another
    #
    # first create two tokens: one on the source server and another one on the destination one
    # fill out the vars below
    # create a cronjob with this script
    # eg:
    # 30 */6 * * * /path-to/technitium-sync.sh

    set -euxo pipefail

    src_dns_server='source.ip.address'
    dst_dns_server='dest.ip.address'
    src_dns_serverdomain='fqdn.of.source.server'
    dst_dns_serverdomain='fqdn.of.dest.server'
    src_dns_token='SOURCE_TECHNITIUM_TOKEN_HERE'
    dst_dns_token='DEST_TECHNITIUM_TOKEN_HERE'
    backup_file="technitium-backup.zip"

    # get_backup

    curl -s "http://$src_dns_server:5380/api/settings/backup?token=$src_dns_token&blockLists=true&logs=false&scopes=true&stats=false&zones=true&allowedZones=true&blockedZones=true&dnsSettings=true&logSettings=true&authConfig=true&apps=true" -o $backup_file

    # restore_backup

    reply=$(curl -s --form file="@$backup_file" "http://$dst_dns_server:5380/api/settings/restore?token=$dst_dns_token&blockLists=true&logs=true&scopes=true&stats=true&apps=true&zones=true&allowedZones=true&blockedZones=true&dnsSettings=true&logSettings=true&deleteExistingFiles=true&authConfig=true")

    # echo $reply | jq .status

    # wait for serve rto come back
    until curl --output /dev/null --silent --head --fail http://$dst_dns_server:5380; do
    printf '.'
    sleep 5
    done

    # set dnsServerDomain on destination server
    curl -X POST "http://$dst_dns_server:5380/api/settings/set?token=$dst_dns_token&dnsServerDomain=$dst_dns_serverdomain"

    # cleanup
    rm -rf $backup_file