This is a network device configuration backup tool.
IMPORTANT: READ INSTRUCTIONS CAREFULLY BEFORE RUNNING THIS PROGRAM
- python >= 3.9
- nornir
- napalm
- paramiko
- netmiko
- Flask
- 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"
sudo apt update && sudo apt-get install python3-venv nginx postgresql
- 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
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.
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
. venv/bin/activate
# For test start
gunicorn -b yourserveraddress:8000 -w 4 app:app
sudo ln -s /opt/supervisor/nabs.service /etc/systemd/system/nabs.service
systemctl daemon-reload
systemctl start nabs
systemctl enable nabs
# Testing starts
systemctl status nabs
# 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
users_helper.py -a <email>
0 9-21/4 * * 1-5 /opt/NABS/venv/bin/python /opt/NABS/backuper.py >/dev/null 2>&1
0 0 * * 1-5 /opt/NABS/venv/bin/python /opt/NABS/netbox_devices_importer.py >/dev/null 2>&1
- 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 NABS
sudo systemctl restart nabs
Nornir and Napalm teams
This project is licensed under the terms of the MIT license.
You can check out the full license here