Metadata-Version: 2.4
Name: borg2mqtt
Version: 0.2.1
Summary: Send borg backup updates over MQTT
Project-URL: Homepage, https://github.com/contagon/borg2mqtt
Project-URL: Bug Reports, https://github.com/contagon/borg2mqtt/issues
Project-URL: Source, https://github.com/contagon/borg2mqtt
Author-email: Easton Potokar <contagon6@gmail.com>
Maintainer-email: Easton Potokar <contagon6@gmail.com>
License: MIT License
        
        Copyright (c) 2023 Easton Potokar
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: borg,hass,mqtt
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3.10
Requires-Dist: paho-mqtt
Requires-Dist: platformdirs
Requires-Dist: python-slugify
Requires-Dist: pyyaml
Description-Content-Type: text/markdown

# Borg -> MQTT
Send borgbackup updates over MQTT, including support for Home Assistant MQTT autodiscovery. Sensors include

- Total/unique chunks
- (Un)compressed size
- Depuplicated (Un)compressed size
- Total number of backups
- Most recent backup

![](images/ha_example.png)

# Installation
Install on any system as python library using
```bash
pip install borg2mqtt
```
Whatever system it is installed on will need the ssh keys for your backup locations.

# Configuration
borg2mqtt reads MQTT and repository information from a configuration yaml file. An example configuration file can be generated by running
```bash
borg2mqtt -c path/config.yml generate
```
If portion `path/config.yml` is left off, borg2mqtt defaults to saving/looking for the configuration file at `$HOME/.config/borg2mqtt/config.yml`.

The configuration file is mostly self-explanatory and looks as follows:
```yaml
# -------------- Sample configuration file -------------- #
# These are the default MQTT values - none are required
mqtt:
  host: localhost
  port: 1883
  user: ""
  password: ""

# Put in as many repositories as desired
repos:
    # Required
  - repo: user@address:/path/to/backup
    # Optional, defaults to the same as repo if not specified
    # This will be used to make entity_ids in HA
    name: Local Data
    # Optional
    key: ""
    # Optional, will use the given ssh command
    # Can be used to authenticate with a ssh key (ssh -i /path-to-key)
    rsh: ""
    # Optional, choose one of kB, MB, GB, TB. Defaults to GB.
    units: GB
```

# Usage
To send the Home Assistant MQTT auto-discovery message, run
```bash
borg2mqtt setup
```

Then to update sensor information run
```bash
borg2mqtt update
```
This can be included in a cron job, borgmatic, etc to send updates as needed. As this is a "local push" option, it should be more efficient than any local polling option that could be included in Home Assistant.

Additionally, a single repository can be updated through it's name found in the configuration file by
```bash
borg2mqtt update -n "My Repo"
```

# Additional Options
All options can always be shown by using flag `--help`. Additionally, varying levels of verbose output can be included through `-vvv`, put before the command type.

# Contributing
All pull requests are more than welcome. Please usse the pre-commit hooks to verify your code before making a pull request. If any bugs are found, feel free to open an issue with your verbose output (`-vvv`) included.
