Based off https://gist.github.com/millerdev/547bac773483402554797e578fbd238f
export CONTAINER_NAME=open-chat-studio-db-1
export VOLUME_NAME=open-chat-studio_postgres_data
Check that these are correct:
docker ps | grep $CONTAINER_NAME
docker volume inspect $VOLUME_NAME
docker exec -i $CONTAINER_NAME pg_dumpall -U postgres | gzip > pg-backup.sql.gz
inv down
Create new volume:
docker volume create --name "${VOLUME_NAME}_old"
Copy data from old to new:
docker run --rm -it -v $VOLUME_NAME:/from -v "${VOLUME_NAME}_old":/to alpine ash -c 'cd /from ; cp -av . /to'
Remove old volume:
docker volume rm $VOLUME_NAME
Change the image tag / name
inv up
gzip -cd pg-backup.sql.gz | docker exec -i $CONTAINER_NAME psql -U postgres