Skip to main content

Posts

Showing posts with the label mikrotik ssh

Automating Mikrotik Backup using Python

When you have so many Mikrotik devices on your network, configuring all of them at once would be a difficult task. I have about 400 devices on my network and today I wanted to make a backup from them so I wrote the following python script for backup. you can do any command with this. I hope this is useful to you. The project can be downloaded from GitHub: https://github.com/pooriaghaedi/mikback/blob/master/mikback.py requirements I used python3.6 for this script. you need to install Paramiko package and re for regular expression if you need.    pip3.6 install Paramiko Here we have 3 functions, connect, backup and generate_file_name. Connect      the connect function initiates a new ssh connection. Generate_file_name      it gets the Mikrotik's hostname from system identity and adds its IP to the end of it. Backup      creates a backup file with the name generated from the previous function and then download it us...