Metadata-Version: 2.4
Name: rosbak
Version: 0.1.0
Summary: Mikrotik RouterOS backup tool
Home-page: https://github.com/divi255/rosbak
Author: Sergei S.
Author-email: s@makeitwork.cz
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Communications
Classifier: Topic :: System :: Archiving :: Backup
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyYAML>=6.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Mikrotik RouterOS backup tool

## Installation

```shell
python3 -m pip install rosbak
```

## What is rosbak

**rosbak** is a Python command line tool which allows backup Mikrotik RouterOS
routers and switches.

Keeping backup files inside RouterOS is usually unsafe, as when the equipment
fail, you have no access to them.

**rosbak** performs RouterOS backup and copies files to the specified location.

# Requirements

* Python >= 3.9 and PyYAML >= 6.0
* OpenSSH clients with legacy SCP support (`scp -O`, OpenSSH >= 8.7)
* RouterOS >= 6.45, as **rosbak** uses scp
* RouterOS ssh service should be turned on
* You should have an access to RouterOS host

## Usage

```shell
rosbak [options] <host>
```

e.g.

```
rosbak -d /backups router1
```

## Configuration

You may put configuration to */usr/local/etc/rosbak.yml*

Configuration contains global variable *dir* which points to default backup
location (you may use {host} param e.g. /backups/{host}, in this case backups
are stored e.g. to */backups/router1*)

Host sections in configuration file may contain router IP (*addr*), port,
backup *delay*, etc.

Configuration file is optional.

## Why backup delay

RouterOS performs backups in background. Backup delay param is required to ask
**rosbak** wait the specified number of seconds before copying backup.

## Export

Command line param *-x* or *export: true* in host configuration tells
**rosbak** to perform configuration export as well (*/export file=...*)

Configuration exports are useful when you need to restore backup partially,
manually copying settings one-by-one (e.g. when restoring it on the another
model).

## Copyright and warranty

**rosbak** is provided as-is under MIT license. **rosbak** is a 3rd party tool
and is not affiliated with SIA Mikrotīkls.

## Version 0.1.0

Uses safe YAML loading (compatible with PyYAML 6), argument-list subprocesses
instead of local shell commands, and legacy SCP explicitly for RouterOS when
using modern OpenSSH clients. Existing configuration files and CLI options
are retained. Precedence: CLI > host section > global settings > defaults;
explicit `false` and delay `0` are respected. Empty YAML files are allowed.
Backup names accept letters, digits, dots, underscores and hyphens, not paths.

SSH uses batch mode and existing host-key verification: authorize the key and
verify the host interactively first. No passwords or host-check bypasses.
Nested destination directories are created automatically. Downloads use private
temporary files and atomic replacement; local backups are mode 0600. Remote
backup/export files are removed only after all downloads succeed, unless
`--keep` is set. Errors return exit status 1. Avoid concurrent backups with
the same custom name. `--delay` remains available for slower devices.

Development checks:

```shell
python3 -m unittest discover -s tests -v
python3 -m pip wheel --no-deps . -w dist
```
