This is a scipt which create backups from a mikrotik device by connecting to it via SSH, and copying over the created backup to a server.
It has implemented backup retention divided into:
- hourly
- daily
- weekly
- monthly
it's supposed to be run in the background, so it's best if it's envoked at startup. The script itself has fields which have to be filled in order for the script to work.
- Generate ssh key-pair
ssh-keygen -t ed25519 -N "" -f private.key- Adjust environmental variables in
config.envaccording to your needs:
ROUTER_USERNAME=admin
PRIVATE_KEY_PATH=private.key
ROUTER_HOSTNAME=198.168.88.1
ROUTER=MikroTik
In mikrotik device settings create user ex. backup with full permissions and import your public ssh key to it.
- Source your adjusted config.env
set -o
source config.env
set +o- Execute script
./mikrotik-backup-tool.shdocker run \
--rm \
--env-file config.env \
-v ~/private.key:/opt/private.key:ro \
-v ./backups/:/opt/backups/ \
mikrotik-backup-tool:latest