Skip to main content

Usage

opnsense-backup is a simple tool to fetch configuration backups from the opnsense firewall.

Arguments

-h, --help

show the help message and exit.

-c FILE, --config FILE

the configuration file (default: ~/.config/opnsense-backup/config.yml)

-o FILE, --output FILE

the output file. The file name can contain strftime directives. If the argument is specified, directory, name and keep fields of the configuration are ignored.

Configuration file

The opnsense-backup needs a configuration file (default ~/.config/opnsense-backup/config.yml). As the file contains secrets, take care to set reasonable permissions. The file is in the YAML format.

Configuration file

opnsense:
   url: https://opnsense
   key: ...
   secret: ...
   ssl_verify: true|false|/path/to/custom_cert.pem
   backup_password: ...
output:
   directory: .
   name: "opnsense-%Y%m%d-%H%M.xml"
   keep: 12

All fields except key and secret are optional. The user the API key was generated for needs to have the Diagnostics: Configuration History permission and ideally nothing else.

url is a host name or an IP address.

If backup_password is specified, the backup file is encrypted in the way the OPNsense does that (as of 25.7.10). It can also be decrypted manually using

openssl aes-256-cbc -d -base64 -md sha512 -pbkdf2 -iter 100000 -in ...

name specifies the name of the output file. strftime directives are allowed.

keep removes all but the most recent *.xml files from the directory, that in this case has to be specified and has to be an absolute path.

directory has to already exist. As the backup is not encrypted and contains secrets the permissions should be set accordingly.

Observability

The backups done can be exported through prometheus text-file format and consumed by the node exporter’s textfile collector. If the metrics key exists, the file is atomically populated after each backup run.

metrics:
    directory: "/var/local/lib/prom_metrics"
    suffix: "my-opnsense"

directory is mandatory and specifies the path of the directory passed as the --collector.textfile.directory for the node_exporter. It has to already exist. suffix is optional and will be appended to the file name to distinguish metrics files generated by different configurations. For the above configuration the full file name will be /var/local/lib/prom_metrics/opnsense-backup-my-opnsense.prom.

Metadata

Release files for opnsense-backup 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opnsense-backup 0.1.0
File Size Uploaded
opnsense_backup-0.1.0.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opnsense-backup 0.1.0
File Interpreter ABI Platform
opnsense_backup-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / opnsense_backup-0.1.0.tar.gz

Download URL opnsense_backup-0.1.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b60716da142d5d4e4f31e8a4c6fa8cf85893257570a349ffaec57d30cda69180
BLAKE2b-256 checksum
How to use checksums
758ee2e324adbccfcd1ab87a7ea201a885a05ba3e3deb49e43c88104ea2dbd3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / opnsense_backup-0.1.0-py3-none-any.whl

Download URL opnsense_backup-0.1.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7ccf3a9b87347b443b251ab2f871dde4e4780959c42616bccc64ffe48236e1c
BLAKE2b-256 checksum
How to use checksums
f894623c459879ab4bbbc7b54baa8f459ad258b3246947ea0013b4e348fbff53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page