how restore SQL file to docker container ? #859
Unanswered
jancovic
asked this question in
Getting Help
Replies: 1 comment
-
OK, I've successfully mounted restore SQL file with below code #postgres but I got error with this command executed in container postgres logged as user postgres : psql -c 'drop database netbox' id |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
I read this article about how replicate netbox:
https://docs.netbox.dev/en/stable/administration/replicating-netbox/
psql -c 'drop database netbox' psql -c 'create database netbox' psql netbox < netbox.sql
But here is missing part how to restore it in docker app
I checked also docker article:
https://github.com/netbox-community/netbox-docker/wiki/Troubleshooting
Restore that database:
Stop all NetBox instances that access the db
docker compose stop netbox netbox-worker netbox-housekeeping
Restore the DB dump
gunzip -c db_dump.sql.gz | docker-compose exec -T postgres sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'
But this not works for me as I got sql errors that tables already exist
So I would like to use 1st option with
psql -c 'drop database netbox'..
But question is what is easiest way to mount my sql restore folder to docker container, ( netbox-docker-postgres-1 ) ?
I think I have to edit somehow this section in docker-compose.yaml, to add mountpoint e.g. /restore
postgres:
image: postgres:14-alpine
env_file: env/postgres.env
volumes:
- netbox-postgres-data:/var/lib/postgresql/data
Beta Was this translation helpful? Give feedback.
All reactions