2016-07-08 16:00:53 -04:00
# Install the Latest Code
As with the initial installation, you can upgrade NetBox by either downloading the latest release package or by cloning the `master` branch of the git repository.
## Option A: Download a Release
2016-07-12 16:57:00 -04:00
Download the [latest stable release ](https://github.com/digitalocean/netbox/releases ) from GitHub as a tarball or ZIP archive. Extract it to your desired path. In this example, we'll use `/opt/netbox` .
Download and extract the latest version:
2016-07-08 16:00:53 -04:00
2016-11-30 12:07:51 -05:00
```no-highlight
2016-07-08 16:00:53 -04:00
# wget https://github.com/digitalocean/netbox/archive/vX.Y.Z.tar.gz
# tar -xzf vX.Y.Z.tar.gz -C /opt
# cd /opt/
2018-03-05 09:21:10 +01:00
# ln -sfn netbox-X.Y.Z/ netbox
2016-07-08 16:00:53 -04:00
```
Copy the 'configuration.py' you created when first installing to the new version:
2016-07-12 16:57:00 -04:00
2016-11-30 12:07:51 -05:00
```no-highlight
2018-03-05 09:21:10 +01:00
# cp netbox-X.Y.Z/netbox/netbox/configuration.py netbox/netbox/netbox/configuration.py
2016-07-08 16:00:53 -04:00
```
2018-02-27 15:54:25 -05:00
Be sure to replicate your uploaded media as well. (The exact action necessary will depend on where you choose to store your media, but in general moving or copying the media directory will suffice.)
```no-highlight
2018-03-05 09:21:10 +01:00
# cp -pr netbox-X.Y.Z/netbox/media/ netbox/netbox/
2018-02-27 15:54:25 -05:00
```
2018-03-01 15:05:51 -08:00
Also make sure to copy over any reports that you've made. Note that if you made them in a separate directory (`/opt/netbox-reports` for example), then you will not need to copy them - the config file that you copied earlier will point to the correct location.
```no-highlight
# cp -r /opt/netbox-X.Y.X/netbox/reports /opt/netbox/netbox/reports/
```
2016-07-12 16:57:00 -04:00
If you followed the original installation guide to set up gunicorn, be sure to copy its configuration as well:
2016-07-08 16:00:53 -04:00
2016-11-30 12:07:51 -05:00
```no-highlight
2018-03-05 09:21:10 +01:00
# cp netbox-X.Y.Z/gunicorn_config.py netbox/gunicorn_config.py
2016-07-08 16:00:53 -04:00
```
2017-01-26 15:28:11 -08:00
Copy the LDAP configuration if using LDAP:
```no-highlight
2018-03-05 09:21:10 +01:00
# cp netbox-X.Y.Z/netbox/netbox/ldap_config.py netbox/netbox/netbox/ldap_config.py
2017-01-26 15:28:11 -08:00
```
2016-07-12 16:57:00 -04:00
## Option B: Clone the Git Repository (latest master release)
This guide assumes that NetBox is installed at `/opt/netbox` . Pull down the most recent iteration of the master branch:
2016-11-30 12:07:51 -05:00
```no-highlight
2016-07-12 16:57:00 -04:00
# cd /opt/netbox
2016-07-08 16:00:53 -04:00
# git checkout master
2016-07-12 16:57:00 -04:00
# git pull origin master
2016-07-08 16:00:53 -04:00
# git status
```
# Run the Upgrade Script
Once the new code is in place, run the upgrade script (which may need to be run as root depending on how your environment is configured).
2016-11-30 12:07:51 -05:00
```no-highlight
2016-07-08 16:00:53 -04:00
# ./upgrade.sh
```
2017-06-09 12:13:47 -04:00
!!! warning
The upgrade script will prefer Python3 and pip3 if both executables are available. To force it to use Python2 and pip, use the `-2` argument as below.
```no-highlight
# ./upgrade.sh -2
```
2016-07-08 16:00:53 -04:00
This script:
* Installs or upgrades any new required Python packages
* Applies any database migrations that were included in the release
* Collects all static files to be served by the HTTP service
2017-05-23 22:36:40 -04:00
!!! note
It's possible that the upgrade script will display a notice warning of unreflected database migrations:
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
2017-06-08 10:58:30 +02:00
This may occur due to semantic differences in environment, and can be safely ignored. Never attempt to create new migrations unless you are intentionally modifying the database schema.
2017-05-23 22:36:40 -04:00
2016-07-08 16:00:53 -04:00
# Restart the WSGI Service
Finally, restart the WSGI service to run the new code. If you followed this guide for the initial installation, this is done using `supervisorctl` :
2016-11-30 12:07:51 -05:00
```no-highlight
2016-07-08 16:00:53 -04:00
# sudo supervisorctl restart netbox
```