pdnsbackup


Namepdnsbackup JSON
Version 0.11.5 PyPI version JSON
download
home_pagehttps://github.com/dmachard/python-pdnsbackup
SummaryBackup tool for PowerDNS database
upload_time2024-11-28 21:06:14
maintainerNone
docs_urlNone
authorDenis MACHARD
requires_pythonNone
licenseNone
keywords powerdns pdns database backup
VCS
bugtrack_url
requirements aiomysql python-dotenv pyyaml boto3 prometheus-client
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Build](https://github.com/dmachard/python-pdnsbackup/workflows/Build/badge.svg) ![Testing](https://github.com/dmachard/python-pdnsbackup/workflows/Testing/badge.svg) ![Pypi](https://github.com/dmachard/python-pdnsbackup/workflows/Publish/badge.svg)

# 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.13.x](https://img.shields.io/badge/python%203.13.x-tested-blue) ![python 3.12.x](https://img.shields.io/badge/python%203.12.x-tested-blue) ![python 3.11.x](https://img.shields.io/badge/python%203.11.x-tested-blue)

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

```python
pip install pdnsbackup
```

## Usage

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

```bash
$ 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](/pdnsbackup/config.yml):

- 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](./metrics.txt) 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

```bash
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

```bash
python -m venv venv
source venv/bin/activate
```

Install requirements and run-it

```bash
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

```bash
sudo docker build . --file Dockerfile -t pdnsbackup
```

## Run tests

![powerdns auth 4.9.x](https://img.shields.io/badge/pdns%204.9.x-tested-green) ![powerdns auth 4.8.x](https://img.shields.io/badge/pdns%204.8.x-tested-green)

Run all tests

```bash
python -m unittest discover -v tests/
```

Run one by one

```bash
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
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dmachard/python-pdnsbackup",
    "name": "pdnsbackup",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "powerdns pdns database backup",
    "author": "Denis MACHARD",
    "author_email": "d.machard@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/21/d5/b3ab3b8514bbe8f3ce6aa8854175cd74192767285b112bb46a9b0b199974/pdnsbackup-0.11.5.tar.gz",
    "platform": "any",
    "description": "![Build](https://github.com/dmachard/python-pdnsbackup/workflows/Build/badge.svg) ![Testing](https://github.com/dmachard/python-pdnsbackup/workflows/Testing/badge.svg) ![Pypi](https://github.com/dmachard/python-pdnsbackup/workflows/Publish/badge.svg)\n\n# What is this?\n\nBackup tool for PowerDNS database (MySQL) to local or S3 storage in bind format. Open metrics  are also computed on your feched zones.\n\n## PyPI\n\n![python 3.13.x](https://img.shields.io/badge/python%203.13.x-tested-blue) ![python 3.12.x](https://img.shields.io/badge/python%203.12.x-tested-blue) ![python 3.11.x](https://img.shields.io/badge/python%203.11.x-tested-blue)\n\nDeploy the `pdnsbackup` tool in your server with the pip command.\n\n```python\npip install pdnsbackup\n```\n\n## Usage\n\nAfter installation, you can execute the `pdnsbackup` to start-it.\n\n```bash\n$ pdnsbackup -h\nusage: -c [-h] [-c C] [-e E] [-v]\n\noptions:\n  -h, --help  show this help message and exit\n  -c C        external config file\n  -e E        env config file\n  -v          debug mode\n```\n\n## Configuration\n\nThis tool can be configurated with severals ways. See the default [config file](/pdnsbackup/config.yml):\n\n- from external configuration file (`-c config` argument)\n\n- from environment variables (`-e env file` argument)\n\n| Variables | Description |\n| ------------- | ------------- |\n| PDNSBACKUP_DEBUG | debug mode 1 or 0 |\n| PDNSBACKUP_GMYSQL_ENABLED | set to 1 to enable gmysql backend, enabled by default |\n| PDNSBACKUP_GMYSQL_HOST | mysql port, default is 127.0.0.1 |\n| PDNSBACKUP_GMYSQL_PORT | mysql port, default is 3306 |\n| PDNSBACKUP_GMYSQL_SSL | enable ssl, default is 0 |\n| PDNSBACKUP_GMYSQL_DBNAME | mysql database name |\n| PDNSBACKUP_GMYSQL_USER | mysql user |\n| PDNSBACKUP_GMYSQL_PASSWORD | mysql password  |\n| PDNSBACKUP_FILE_ENABLED |  set to 1 enable backup to file, enabled by default |\n| PDNSBACKUP_FILE_PATH_BIND | zone bind path in named.conf  |\n| PDNSBACKUP_FILE_PATH_OUTPUT | output folder of the export |\n| PDNSBACKUP_S3_ENABLED |  set to 1 enable backup to S3 storage, disabled by default |\n| PDNSBACKUP_S3_ENDPOINT_URL | your s3 url |\n| PDNSBACKUP_S3_SSL_VERIFY | disable ssl verify |\n| PDNSBACKUP_S3_ACCESS_KEY_ID | your access key |\n| PDNSBACKUP_S3_SECRET_ACCESS_KEY | your secret access key |\n| PDNSBACKUP_S3_BUCKET_NAME | bucket name |\n| PDNSBACKUP_S3_BACKUP_FILE | backup file name |\n| PDNSBACKUP_S3_BACKUP_DELETE_OLDER | delete backups older than xx days |\n| PDNSBACKUP_METRICS_ENABLED | export open metrics |\n| PDNSBACKUP_METRICS_PROM_FILE | write metrics to file path |\n\n# Metrics\n\nThis tool can be used to compute [statistics](./metrics.txt) on your DNS records.\n\n| Variables | Description |\n| ------------- | ------------- |\n| pdnsbackup_status | Status of the backup process |\n| pdnsbackup_zones_total | Total number of zones |\n| pdnsbackup_zones_empty_total | Total number of empty zones |\n| pdnsbackup_records_total | Total number of records per DNS zones |\n| pdnsbackup_wildcards_total | Total number of DNS wilcards |\n| pdnsbackup_delegations_total | Total number of DNS delegations |\n| pdnsbackup_rrtypes_total | Total number of records per type (A, AAAA, CNAME, ...) |\n\n## Docker run\n\n```bash\nsudo docker run --rm --env-file ./.env --name=pdnsbackup dmachard/pdnsbackup:latest\n```\n\n## Run from source\n\nCreate a `.env` file to populate your variable\n\nCreate a virtualenv\n\n```bash\npython -m venv venv\nsource venv/bin/activate\n```\n\nInstall requirements and run-it\n\n```bash\npython3 -m pip install -r requirements.txt\npython3 -c \"import pdnsbackup; pdnsbackup.run();\"\npython3 -c \"import pdnsbackup; pdnsbackup.run();\" -c tests/config.yml\npython3 -c \"import pdnsbackup; pdnsbackup.run();\" -e tests/.env\n```\n\n## Build and run from docker image\n\n```bash\nsudo docker build . --file Dockerfile -t pdnsbackup\n```\n\n## Run tests\n\n![powerdns auth 4.9.x](https://img.shields.io/badge/pdns%204.9.x-tested-green) ![powerdns auth 4.8.x](https://img.shields.io/badge/pdns%204.8.x-tested-green)\n\nRun all tests\n\n```bash\npython -m unittest discover -v tests/\n```\n\nRun one by one\n\n```bash\npython -m unittest -v tests.test_config\npython -m unittest -v tests.test_parser\npython -m unittest -v tests.test_import\npython -m unittest -v tests.test_export_file\npython -m unittest -v tests.test_export_metrics\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Backup tool for PowerDNS database",
    "version": "0.11.5",
    "project_urls": {
        "Homepage": "https://github.com/dmachard/python-pdnsbackup"
    },
    "split_keywords": [
        "powerdns",
        "pdns",
        "database",
        "backup"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "abdb99afa3f3a9f51ffe3476c38688714d1e2dfa3fdaa84cc8f96703aa7e3e7b",
                "md5": "f597f79b0e066c080fb0b1f80d759634",
                "sha256": "b47af3ada3cdf4dc08ef6faf8eec88a64ff53d2bf11c9fcdda1bbe5d4271566a"
            },
            "downloads": -1,
            "filename": "pdnsbackup-0.11.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f597f79b0e066c080fb0b1f80d759634",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10299,
            "upload_time": "2024-11-28T21:06:13",
            "upload_time_iso_8601": "2024-11-28T21:06:13.330973Z",
            "url": "https://files.pythonhosted.org/packages/ab/db/99afa3f3a9f51ffe3476c38688714d1e2dfa3fdaa84cc8f96703aa7e3e7b/pdnsbackup-0.11.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "21d5b3ab3b8514bbe8f3ce6aa8854175cd74192767285b112bb46a9b0b199974",
                "md5": "a6e18c3bb9d4c8784b870f8aa804ac0e",
                "sha256": "ca7f5a886a7a71b5de2a2df2c09adb916b35f64b0a3d14b7cc7fb213b0e7fe09"
            },
            "downloads": -1,
            "filename": "pdnsbackup-0.11.5.tar.gz",
            "has_sig": false,
            "md5_digest": "a6e18c3bb9d4c8784b870f8aa804ac0e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12697,
            "upload_time": "2024-11-28T21:06:14",
            "upload_time_iso_8601": "2024-11-28T21:06:14.739238Z",
            "url": "https://files.pythonhosted.org/packages/21/d5/b3ab3b8514bbe8f3ce6aa8854175cd74192767285b112bb46a9b0b199974/pdnsbackup-0.11.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-28 21:06:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dmachard",
    "github_project": "python-pdnsbackup",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "aiomysql",
            "specs": [
                [
                    "==",
                    "0.2.0"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    "==",
                    "1.0.1"
                ]
            ]
        },
        {
            "name": "pyyaml",
            "specs": [
                [
                    "==",
                    "6.0.2"
                ]
            ]
        },
        {
            "name": "boto3",
            "specs": [
                [
                    "==",
                    "1.35.68"
                ]
            ]
        },
        {
            "name": "prometheus-client",
            "specs": [
                [
                    "==",
                    "0.21.0"
                ]
            ]
        }
    ],
    "lcname": "pdnsbackup"
}
        
Elapsed time: 0.42777s