Skip to main content

Backup tool for PowerDNS database

Project description

Build Testing Pypi

What is this?

Backup tool for PowerDNS database (MySQL) to local or S3 storage in bind format. Open metrics are also computed on your feched zones.

PyPI

python 3.12.x python 3.11.x

Deploy the pdnsbackup tool in your server with the pip command.

pip install pdnsbackup

Usage

After installation, you can execute the pdnsbackup to start-it.

$ pdnsbackup -h
usage: -c [-h] [-c C] [-e E] [-v]

options:
  -h, --help  show this help message and exit
  -c C        external config file
  -e E        env config file
  -v          debug mode

Configuration

This tool can be configurated with severals ways. See the default config file:

  • from external configuration file (-c config argument)

  • from environment variables (-e env file argument)

Variables Description
PDNSBACKUP_DEBUG debug mode 1 or 0
PDNSBACKUP_GMYSQL_ENABLED set to 1 to enable gmysql backend, enabled by default
PDNSBACKUP_GMYSQL_HOST mysql port, default is 127.0.0.1
PDNSBACKUP_GMYSQL_PORT mysql port, default is 3306
PDNSBACKUP_GMYSQL_SSL enable ssl, default is 0
PDNSBACKUP_GMYSQL_DBNAME mysql database name
PDNSBACKUP_GMYSQL_USER mysql user
PDNSBACKUP_GMYSQL_PASSWORD mysql password
PDNSBACKUP_FILE_ENABLED set to 1 enable backup to file, enabled by default
PDNSBACKUP_FILE_PATH_BIND zone bind path in named.conf
PDNSBACKUP_FILE_PATH_OUTPUT output folder of the export
PDNSBACKUP_S3_ENABLED set to 1 enable backup to S3 storage, disabled by default
PDNSBACKUP_S3_ENDPOINT_URL your s3 url
PDNSBACKUP_S3_SSL_VERIFY disable ssl verify
PDNSBACKUP_S3_ACCESS_KEY_ID your access key
PDNSBACKUP_S3_SECRET_ACCESS_KEY your secret access key
PDNSBACKUP_S3_BUCKET_NAME bucket name
PDNSBACKUP_S3_BACKUP_FILE backup file name
PDNSBACKUP_S3_BACKUP_DELETE_OLDER delete backups older than xx days
PDNSBACKUP_METRICS_ENABLED export open metrics
PDNSBACKUP_METRICS_PROM_FILE write metrics to file path

Metrics

This tool can be used to compute statistics on your DNS records.

Variables Description
pdnsbackup_status Status of the backup process
pdnsbackup_zones_total Total number of zones
pdnsbackup_zones_empty_total Total number of empty zones
pdnsbackup_records_total Total number of records per DNS zones
pdnsbackup_wildcards_total Total number of DNS wilcards
pdnsbackup_delegations_total Total number of DNS delegations
pdnsbackup_rrtypes_total Total number of records per type (A, AAAA, CNAME, ...)

Docker run

sudo docker run --rm --env-file ./.env --name=pdnsbackup dmachard/pdnsbackup:latest

Run from source

Create a .env file to populate your variable

Create a virtualenv

python -m venv venv
source venv/bin/activate

Install requirements and run-it

python3 -m pip install -r requirements.txt
python3 -c "import pdnsbackup; pdnsbackup.run();"
python3 -c "import pdnsbackup; pdnsbackup.run();" -c tests/config.yml
python3 -c "import pdnsbackup; pdnsbackup.run();" -e tests/.env

Build and run from docker image

sudo docker build . --file Dockerfile -t pdnsbackup

Run tests

powerdns auth 4.9.x powerdns auth 4.8.x

Run all tests

python -m unittest discover -v tests/

Run one by one

python -m unittest -v tests.test_config
python -m unittest -v tests.test_parser
python -m unittest -v tests.test_import
python -m unittest -v tests.test_export_file
python -m unittest -v tests.test_export_metrics

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdnsbackup-0.11.3.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

pdnsbackup-0.11.3-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file pdnsbackup-0.11.3.tar.gz.

File metadata

  • Download URL: pdnsbackup-0.11.3.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pdnsbackup-0.11.3.tar.gz
Algorithm Hash digest
SHA256 fd06364bf7677b2c70c861688973a7748d98d4907fbf8fccab414e7de090fe74
MD5 fd4d0d24b8c025bdaf18a3b770c5e9f3
BLAKE2b-256 26e6c8c2bd2c1849d8125301468dd0f6a32a86f56e8e5793ca400abd32aaa019

See more details on using hashes here.

File details

Details for the file pdnsbackup-0.11.3-py3-none-any.whl.

File metadata

  • Download URL: pdnsbackup-0.11.3-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pdnsbackup-0.11.3-py3-none-any.whl
Algorithm Hash digest
SHA256 39690aca0ffd1cf5e3e6800fb7b2aedf18b9395fa11d2934384a17c766a56db8
MD5 7d96d9a59e0095daac518b45f5e0eedb
BLAKE2b-256 e33c50b2a1f5ce89b2cfbe196da04af1824845b8aaf03926ca9b001c9f847403

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page