Brian, thanks for your answer,
I found the following page very helpful:
here are the exact commands to successfully dump and restore the database, especially in a netbox-docker context:
Backup
docker-compose exec -T netbox tar c -zvf - -C /opt/netbox/netbox/media ./ > "${BACKUP_PATH}/${BACKUP_DATE}_media.tgz"
docker-compose exec -T postgres sh -c 'pg_dump -v -Fc -U $POSTGRES_USER $POSTGRES_DB' > "${BACKUP_PATH}/${BACKUP_DATE}.pgdump"
Restore
docker-compose up -d postgres
docker-compose exec -T postgres sh -c 'pg_restore -v -Fc -c -U $POSTGRES_USER -d $POSTGRES_DB' < "${BACKUP_PATH}/${BACKUP_DATE}.pgdump"
docker-compose up -d
docker-compose exec -T netbox tar x -zvf - -C /opt/netbox/netbox/media < "${BACKUP_PATH}/${BACKUP_DATE}_media.tgz"
The thing I did a bit differently was that I first startet up _all_ containers with "docker-compose up -d" waited for all of them to initialize and then shut them down with "docker-compose stop". After starting only the postgres container as described I logged into the container with "docker exec -it netbox-docker_postgres_1 /bin/bash", connected to the DBMS, deleted and recreated the netbox DB:
psql -U netbox postgres
drop database netbox;
create database netbox;
Afterwards restore worked quite flawless, but I had to run the restore two or three times because during the first run many errors occurred due to references to not yet existing entries. In the end the only error that was still present was one complaining about the missing "postgres role" which simply is not there when using netbox-docker. But this shouldn't be any problem.
Furthermore I have to add that with the commands above the restore was successfull both with Postgres 9.6 and 12.5 (pg_dump version 9.6 -> pg_restore version 9.6/12.5)
The main issue I was running into yesterday was that for reasons unknown someone had set up the old netbox installation I dumped the DB from was configured to not use the db "netbox" but "netbox2" - probably because "netbox" was broken at some point in the past. The commands above use environment variable $POSTGRES_DB which reflects the proper db name on the system the command is run on ("netbox2" on the source, "netbox" on the target).
I hope these hints might be helpful for somebody running into similar migration issues as I did. :-)
regards
Stephan