Updated Troubleshooting (markdown)

daniel-zook 2023-01-05 10:55:10 -05:00
parent a4ab6a0af1
commit ebd5aa497e

@ -8,25 +8,25 @@ If your issue is not here, look through [the existing issues][issues] and eventu
See all running containers: See all running containers:
```bash ```bash
docker compose ps docker-compose ps
``` ```
See all logs: See all logs:
```bash ```bash
docker compose logs -f docker-compose logs -f
``` ```
See just the NetBox logs: See just the NetBox logs:
```bash ```bash
docker compose logs -f netbox docker-compose logs -f netbox
``` ```
Stop it all: Stop it all:
```bash ```bash
docker compose stop docker-compose stop
``` ```
Reset the project: Reset the project:
@ -34,7 +34,7 @@ Reset the project:
> ⚠️ **This will remove any Netbox-related data.** > ⚠️ **This will remove any Netbox-related data.**
```bash ```bash
docker compose down -v --remove-orphans docker-compose down -v --remove-orphans
git reset --hard origin/release git reset --hard origin/release
```` ````
@ -43,7 +43,7 @@ git reset --hard origin/release
Start the Netbox Container shell, e.g. to get access to `./manage.py` or look for files: Start the Netbox Container shell, e.g. to get access to `./manage.py` or look for files:
``` ```
docker compose exec netbox /bin/bash docker-compose exec netbox /bin/bash
``` ```
To load the Python environment for Netbox run: To load the Python environment for Netbox run:
@ -56,23 +56,23 @@ source /opt/netbox/venv/bin/activate
Access the database: Access the database:
```bash ```bash
docker compose exec postgres sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB' docker-compose exec postgres sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'
``` ```
Take a database backup Take a database backup
```bash ```bash
docker compose exec -T postgres sh -c 'pg_dump -cU $POSTGRES_USER $POSTGRES_DB' | gzip > db_dump.sql.gz docker-compose exec -T postgres sh -c 'pg_dump -cU $POSTGRES_USER $POSTGRES_DB' | gzip > db_dump.sql.gz
``` ```
Restore that database: Restore that database:
```bash ```bash
# Stop all NetBox instances that access the db # Stop all NetBox instances that access the db
docker compose stop netbox netbox-worker netbox-housekeeping docker-compose stop netbox netbox-worker netbox-housekeeping
# Restore the DB dump # Restore the DB dump
gunzip -c db_dump.sql.gz | docker compose exec -T postgres sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB' gunzip -c db_dump.sql.gz | docker-compose exec -T postgres sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'
``` ```
### File Operations ### File Operations
@ -80,7 +80,7 @@ gunzip -c db_dump.sql.gz | docker compose exec -T postgres sh -c 'psql -U $POSTG
Backup of the _media_ directory, which contains uploaded images. Backup of the _media_ directory, which contains uploaded images.
```bash ```bash
docker compose exec -T netbox tar c -jf - -C /opt/netbox/netbox/media ./ > media-backup.tar.bz2 docker-compose exec -T netbox tar c -jf - -C /opt/netbox/netbox/media ./ > media-backup.tar.bz2
``` ```
Restore of the _media_ directory: Restore of the _media_ directory:
@ -88,7 +88,7 @@ Restore of the _media_ directory:
> ⚠️ This may overwrite files in the media directory! > ⚠️ This may overwrite files in the media directory!
```bash ```bash
docker compose exec -T netbox tar x -jvf - -C /opt/netbox/netbox/media < media-backup.tar.bz2 docker-compose exec -T netbox tar x -jvf - -C /opt/netbox/netbox/media < media-backup.tar.bz2
``` ```
### Netbox Worker Operations ### Netbox Worker Operations
@ -96,7 +96,7 @@ docker compose exec -T netbox tar x -jvf - -C /opt/netbox/netbox/media < media-b
See the status of the worker queue: See the status of the worker queue:
```bash ```bash
docker compose run --rm netbox-worker /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqstats docker-compose run --rm netbox-worker /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqstats
``` ```
### Netbox Shell (nbshell) ### Netbox Shell (nbshell)
@ -104,7 +104,7 @@ docker compose run --rm netbox-worker /opt/netbox/venv/bin/python /opt/netbox/ne
The _nbshell_ is a way to quickly get programmatic access to Netbox. It offers about the same interface as the Netbox REST API. The _nbshell_ is a way to quickly get programmatic access to Netbox. It offers about the same interface as the Netbox REST API.
```bash ```bash
docker compose run --rm netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py nbshell docker-compose run --rm netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py nbshell
``` ```
## Frequently Asked Questions (FAQ) and Common Problems ## Frequently Asked Questions (FAQ) and Common Problems
@ -149,9 +149,9 @@ Update your local installation:
git pull origin release git pull origin release
# Fetch the newest containers # Fetch the newest containers
docker compose rm -fs netbox netbox-worker docker-compose rm -fs netbox netbox-worker
docker compose pull docker-compose pull
docker compose up -d netbox netbox-worker docker-compose up -d netbox netbox-worker
``` ```
### Webhooks don't work ### Webhooks don't work
@ -168,7 +168,7 @@ Then make sure that the `redis` container and at least one `netbox-worker` are r
```bash ```bash
# check the container status # check the container status
$ docker compose ps $ docker-compose ps
Name Command State Ports Name Command State Ports
-------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------
@ -178,7 +178,7 @@ netbox-docker_postgres_1 docker-entrypoint.sh postgres Up 5432/tc
netbox-docker_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp netbox-docker_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
# connect to redis and send PING command: # connect to redis and send PING command:
$ docker compose run --rm -T redis sh -c 'redis-cli -h redis -a $REDIS_PASSWORD ping' $ docker-compose run --rm -T redis sh -c 'redis-cli -h redis -a $REDIS_PASSWORD ping'
Warning: Using a password with '-a' option on the command line interface may not be safe. Warning: Using a password with '-a' option on the command line interface may not be safe.
PONG PONG
``` ```
@ -188,14 +188,14 @@ If `redis` and the `netbox-worker` are not available, make sure you have updated
Everything's up and running? Then check the log of `netbox-worker` and/or `redis`: Everything's up and running? Then check the log of `netbox-worker` and/or `redis`:
```bash ```bash
docker compose logs -f netbox-worker docker-compose logs -f netbox-worker
docker compose logs -f redis docker-compose logs -f redis
``` ```
Still no clue? You can connect to the `redis` container and have it report any command that is currently executed on the server: Still no clue? You can connect to the `redis` container and have it report any command that is currently executed on the server:
```bash ```bash
docker compose run --rm -T redis sh -c 'redis-cli -h redis -a $REDIS_PASSWORD monitor' docker-compose run --rm -T redis sh -c 'redis-cli -h redis -a $REDIS_PASSWORD monitor'
# Hit CTRL-C a few times to leave # Hit CTRL-C a few times to leave
``` ```