-
-
Save iceman73/7e9e412d13331825611a582be5ef0b27 to your computer and use it in GitHub Desktop.
sync two technitium servers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment