netbox-community / netbox-docker

🐳 Docker Image of NetBox

Home Page:https://github.com/netbox-community/netbox-docker/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improved documentation for database restoration process

vincemulhollon opened this issue · comments

Current Behavior

I tried to restore an older schema database backup following the procedure at

https://github.com/netbox-community/netbox-docker/wiki/Troubleshooting#database-operations

The problem I ran into is the documented strategy works for restoring a current schema backup onto a current schema database. However, if you try to restore a "couple month old" schema database onto a fresh installation of netbox, the fresh empty new schema has changed such that full restoration is not possible and randomly some data is lost. All VM's cluster name entries failed to restore, also, I think, all devices failed to restore in general.

Expected Behavior

I expected the database to restore, which it did not.

The existing procedure "stops everything but postgresql" so on my restoration machine I wiped everything then did the logical opposite "only start postgresql". Then the process of restoring the old schema database was 100% successful, then when I started everything up, the database migration to the latest schema was 100% successful.

I'm not sure how to improve the docs and whatever strategy you think best is probably fine.

One possible solution would be to add the commands to do a total database wipe before doing a restoration. Restoring into a completely clean and empty database is probably always a good idea.

Another solution might be to document there are two restoration processes, if restoring a new schema DB onto a new install, the existing docs work fine, but if restoring an old schema DB backup onto a new install, then a better solution is to "only start postgres" rather than "start everything then shut down everything thats not postgres" to prevent schema conflicts.

Perhaps there is an even better way to phrase this in the docs.

Anyway, thanks for your efforts supporting netbox, its much appreciated, and hopefully this doc suggestion helps a little, somehow, have a great day!

Docker Compose Version

Docker Compose version v2.21.0

Docker Version

Client: Docker Engine - Community
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.20.10
 Git commit:        afdd53b
 Built:             Thu Oct 26 09:08:01 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.7
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.10
  Git commit:       311b9ff
  Built:            Thu Oct 26 09:08:01 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.24
  GitCommit:        61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
 runc:
  Version:          1.1.9
  GitCommit:        v1.1.9-0-gccaecfc
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

The git Revision

b47e85a

The git Status

On branch release
Your branch is up to date with 'origin/release'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
docker-compose.override.yml.old
media-backup.tar.bz2

nothing added to commit but untracked files present (use "git add" to track)

Startup Command

docker compose up -d

NetBox Logs

Really?  There's 295 lines and its working fine and its all stuff like:
netbox-docker-netbox-1  | 127.0.0.1 - - [11/Nov/2023:18:01:17 +0000] "GET /api/ HTTP/1.1" 200 510 "-
" "curl/7.88.1"

Content of docker-compose.override.yml

version: '3.4'
services:
  netbox:
    ports:
      - 8000:8080

Can you please add a detailed procedure for upgrading the DB created by an old Postgresql version to newer one ?

The PostgreSQL upgrade is describe in the Wiki: https://github.com/netbox-community/netbox-docker/wiki/Updating#postgresql-update

The Wiki is open an can be improved by anybody.