8a0af08ff9f06b6203f012e7915aa33ca9c222b7
Co-Authored-By: Claude Opus 5.5 <[email protected]>
NetBox Updater
Automated upgrade script for self-hosted NetBox installations under
/opt/netbox.
| Type | Bash script |
| Platform | Linux server running NetBox |
| Repository | https://git.mrblake.cc/MrBlake/NetBox-Updater |
Features
- Downloads and extracts the requested NetBox release
- Carries over
configuration.py,ldap_config.py,media/,scripts/,reports/andgunicorn.py - Carries over or creates
local_requirements.txt(plugins), addingdjango-auth-ldapautomatically when an LDAP configuration is detected - Swaps directories (
netbox→netbox_old, new release →netbox) - Runs NetBox's
upgrade.sh
Requirements
- Root privileges (
sudo) - An existing installation under
/opt/netbox wget,tarandcurl- Neither
/opt/netbox_oldnor/opt/netbox-<version>may exist; the script aborts otherwise so nothing is overwritten
Usage
Download and run in one step, passing the target version without a leading v:
curl -fsSL https://git.mrblake.cc/MrBlake/NetBox-Updater/raw/branch/main/upgrade.sh | sudo bash -s -- 4.1.5
Or with wget:
wget -qO- https://git.mrblake.cc/MrBlake/NetBox-Updater/raw/branch/main/upgrade.sh | sudo bash -s -- 4.1.5
Replace 4.1.5 with the desired target version (see
NetBox releases).
To review the script before running it, download it first:
wget https://git.mrblake.cc/MrBlake/NetBox-Updater/raw/branch/main/upgrade.sh
chmod +x upgrade.sh
sudo ./upgrade.sh 4.1.5
Steps in detail
- Download: fetches
vX.Y.Z.tar.gzfrom GitHub and extracts it to/opt/netbox-X.Y.Z. - Copy: transfers configuration, media, scripts, reports and, if present,
gunicorn.pyfrom the existing installation. - Plugins: copies
local_requirements.txtfrom/opt/netbox. If none exists, a default list is created (editable in the script). Ifldap_config.pyexists,django-auth-ldapis added automatically. - Pause for review: the script stops and asks you to check
CSRF_TRUSTED_ORIGINSin the newconfiguration.py(Enter to continue, Ctrl+C to abort). - Directory swap:
/opt/netbox→/opt/netbox_old,/opt/netbox-X.Y.Z→/opt/netbox. - Upgrade: runs
/opt/netbox/upgrade.sh. - Clean-up: deletes the downloaded tarball.
After the upgrade
-
Test NetBox: login, plugins and LDAP if used.
-
If something is wrong, roll back: the previous installation is kept under
/opt/netbox_old. -
Once everything works, remove the old installation:
sudo rm -rf /opt/netbox_old
Languages
Shell
100%