Categorygithub.com/ecadlabs/rosdump
modulepackage
0.1.1
Repository: https://github.com/ecadlabs/rosdump.git
Documentation: pkg.go.dev

# README

Rosdump

CircleCI

rosdump is a tool for backing up and optionally tracking configuration of RouterOS devices.

Use rosdump to:

  • Backup Mikrotik network device configurations to your local file system
  • Backup Mikrotik network device configurations to a git repository
  • Run as a daemon that backs up devices on a predefined schedule

Quick Start

The following example uses the docker image to backup a RouterOS device. Create a config named rosdump.yml on your computer using the example below.

Specify the IP address, admin user and password of your own device.

Config example that writes backup to local filesystem

version: 1

devices:
  list:
    - host: 192.168.88.1
  common: # Overrides per-device settings
    driver: ssh-command
    timeout: 30s # See https://golang.org/pkg/time/#ParseDuration
    command: export
    username: admin
    password: password

storage:
  driver: file
  timeout: 30s
  path: '/opt/backups/{{.host}}/{{.time.UTC.Format "2006-01-02T15:04:05Z07:00"}}'

timeout: 30s # Optional timeout for a whole work cycle
interval: 4h # Duration between backups when running as a daemon

Assuming your config file is named rosdump.yaml, and you have docker installed on your computer, run the following command:

docker run --rm \
        -v $(realpath rosdump.yml):/etc/rosdump.yml \
        -v $(realpath backups):/opt/backups ecadlabs/rosdump

You will now have a backup of your configuration in a directory named backups/ in your present working directory.

Configuration Schema

Exporter drivers

Common options

NameTypeDefaultRequiredDescription
driverstringssh-commandDriver name
timeoutstring/duration1

ssh-command

NameTypeDefaultRequiredDescription
namestringOptional device name
hoststringHost address
portinteger22SSH port
usernamestringUser name
passwordstringPassword
identity_filestringSSH private key file
commandstringexportCommand to run on a remote device

Storage drivers

Common options

NameTypeDefaultRequiredDescription
driverstringDriver name
timeoutstring/duration1

file

NameTypeDefaultRequiredDescription
pathstring/templateDestination path
compressbooleanfalseUse gzip compression

git

NameTypeDefaultRequiredDescription
repository_pathstringLocal repository path. In-memory storage will be used if not specified.
urlstringURL to clone if the specified repository is not initialised. In-memory storage is always empty at startup so cloning will be performed anyway in this case.
pullbooleanPull changes from remote repository on startup (only if cloning is not required, see above).
usernamestringUser name (overrides one from URL)
passwordstringPassword (overrides one from URL)
identity_filestringSSH private key file
remote_namestringName of the remote to be pulled. If empty, uses the default.
reference_namestringRemote branch to clone. If empty, uses HEAD.
pushbooleanPush after commit
ref_specsarraySpecifies what destination ref to update with what source
destination_pathstring/templateTarget path template relative to work tree
namestringAuthor name
emailstringAuthor email
commit_messagestring/templateCommit message

Example config for git storage

version: 1

devices:
  list:
    - host: 192.168.88.1
  common:
    driver: ssh-command
    timeout: 30s
    command: export
    username: admin
    identity_file: /etc/rosdump/routeros_admin_private_key

storage:
  driver: git
  timeout: 30s
  url: [email protected]:yourorg/networkbackups.git
  identity_file: /etc/rosdump/git_deploy_key
  destination_path: '{{.host}}'
  push: true
  name: Network Backup
  email: [email protected]
  commit_message: 'Rosdump backup {{.time.UTC.Format "2006-01-02T15:04:05Z07:00"}}'

timeout: 30s
interval: 4h

Template data fields (transaction metadata)

Currently ssh-command driver exposes all its options (except password) as a transaction metadata. Additionally time field is set to transaction timestamp (see the description of Go time.Time type).

Footnotes

  1. https://golang.org/pkg/time/#ParseDuration 2

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author