Loess.ru

having fun

Backing up Mikrotik RouterOS config to Git repository

#!/bin/sh
cd /home/user/mikrot-config/
/usr/bin/ssh -i /home/user/.ssh/id_rsa admin-ssh-account@ip.address.of.mikrot "export" > /home/user/mikrot-config/mikrot.conf 2>&1
#deletes first line with datetime for committing only config changes
/bin/sed -i '1{/by RouterOS 6/d;}' /home/user/mikrot-config/mikrot.conf
git add ./mikrot.conf
git commit -m "backup as of $(/bin/date +\%Y-\%m-\%d-\%H-\%M-\%S)"

if you need to backup a lot of hosts and webface for backup control, check https://www.ekzorchik.ru/2019/03/backing-up-mikrotik-via-oxidized/ (pdf)

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *

Test your skill: *