Backing up Netbox Docker/updating

I’ve tried to update Netbox several times recently and had various errors. Fun errors like Container netbox-docker-netbox-1 Error don’t help a lot. To update I use:

docker compose down
git checkout release
git pull -p origin release
docker compose pull
docker compose up -d

Seems like the version transition isn’t working as the last 3 updates all broke for various reasons. Given that the Netbox Docker setup uses Postgres I now do the following (enter the date or your UID info where “date” is):

docker compose down
docker compose up -d postgres
docker compose exec -T postgres sh -c 'pg_dump -cU $POSTGRES_USER $POSTGRES_DB' | gzip > db_dump_date.sql.gz
docker compose down
docker volume rm netbox-docker_netbox-postgres-data
git checkout release
git pull -p origin release
docker compose pull
docker compose up -d postgres
gunzip -c db_dump_date.sql.gz | docker compose exec -T postgres sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'
docker compose up -d

YMMV. I really like Netbox, but wish their updates worked better.

Leave a Reply

Your email address will not be published. Required fields are marked *