Git Product home page Git Product logo

nabs's Introduction

Python 3.9 Python 3.10 Python 3.11 Python 3.12 Code Style

Network Automated BackUp System

This is a network device configuration backup tool.

IMPORTANT: READ INSTRUCTIONS CAREFULLY BEFORE RUNNING THIS PROGRAM

Requirements

Software

  • python >= 3.9
  • nornir
  • napalm
  • paramiko
  • netmiko
  • Flask

Device vendors supported

  • Cisco
  • Huawei
  • Eltex
  • If you need another device, then install an additional plugin for NAPALM
  • You can create your own drivers in settings
. venv/bin/activate
pip3 install napalm-"drivername"

Screenshots

Screenshot of Dashboards page Screenshot of Devices page Screenshot of Diff page Screenshot of Diff page context compare Screenshot of Drivers page

Installing

Ubuntu 18.04 & 22.04

sudo apt update && sudo apt-get install python3-venv nginx supervisor postgresql

Clone repo and install dependencies

  • download and setup of virtual environment
cd /opt
git clone https://github.com/Sivolen/NABS
cd NABS
python3 -m venv venv
. venv/bin/activate
pip3 install --upgrade pip || pip install --upgrade pip
pip3 install wheel || pip install wheel
pip3 install -r requirements.txt || pip install -r requirements.txt

Setup configuration

Copy the config_example.py sample settings file to config.py.
Copy the netbox_config_example.yaml sample settings file to config.yaml.
If you are not using NetBox, then edit the netbox_config_example.yaml according to the documentation or add devices manually use "Add" on devices page.
All options are described in the example file.

init DB

Database creation

sudo -u postgres psql
CREATE DATABASE NABS;
CREATE USER NABS WITH ENCRYPTED PASSWORD 'NABS';
GRANT ALL PRIVILEGES ON DATABASE NABS TO NABS;
QUIT;

Enter the username and password from the database in the configuration file in the fields

DBName = "nabs"
DBUser = "nabs"
. venv/bin/activate
flask db init
flask db migrate
flask db upgrade

Running the web server

. venv/bin/activate
# For test start
gunicorn -b yourserveraddress:8000 -w 4 app:app
cp /opt/NABS/supervisor/nabs.conf /etc/supervisor/conf.d/nabs.conf
sudo supervisorctl reload

Configure Nginx

# Create dir for ssl certificate
mkdir certs
# Create ssl certificate
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \
  -keyout certs/key.pem -out certs/cert.pem
 
sudo rm /etc/nginx/sites-enabled/default
sudo cp /opt/NABS/supervisor/nabs /etc/nginx/available/nabs
sudo ln -s /etc/nginx/sites-available/nabs /etc/nginx/sites-enabled/nabs
sudo systemctl restart nginx

Create user

users_helper.py -a <email>

Running the backup script on crontab

0 9-21/4 * * 1-5 /opt/NABS/venv/bin/python /opt/NABS/backuper.py >/dev/null 2>&1

You can import network device data from Netbox or add devices manually.

Run device import from netbox if you need it.

0 0 * * 1-5 /opt/NABS/venv/bin/python /opt/NABS/netbox_devices_importer.py >/dev/null 2>&1

Update

  • Update NABS and virtual environment
cd /opt/NABS
sudo git checkout origin/main
sudo git pull
. venv/bin/activate
pip3 install -r requirements.txt || pip install -r requirements.txt
  • Update DB
. venv/bin/activate
flask db stamp head
flask db migrate
flask db upgrade
  • Check config_example.py for new features and copy them into your config.py
  • Reload supervisor
sudo service supervisor reload

Thanks

Nornir and Napalm teams

License

This project is licensed under the terms of the MIT license.

You can check out the full license here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.