Handy Commands

Find a process by port

lsof -i :[port number]

Close a stubborn process

kill -9 $(pgrep -f [process name] -u $USER)

Upgrade postgres in docker

sudo docker stop appname-postgres
sudo docker rm appname-postgres

sudo docker run -d --cpus=".8" \
-p 0.0.0.0:5432:5432 \
--restart unless-stopped \
-v /appname_pg17betadata:/var/lib/postgresql/data \
-e PGDATA=/var/lib/postgresql/data \
-e POSTGRES_USER=appname_pguser \
-e POSTGRES_PASSWORD=appname_pgpassword \
--name appname-postgres \
--network=appnamenetwork \
postgres:17beta1

sudo docker stop appname-postgres-upgrade
sudo docker rm appname-postgres-upgrade

sudo docker run -d --cpus=".8" \
--restart unless-stopped \
-v /appname_pg17data:/var/lib/postgresql/data \
-e PGDATA=/var/lib/postgresql/data \
-e POSTGRES_USER=appname_pguser \
-e POSTGRES_PASSWORD=appname_pgpassword \
--name appname-postgres-upgrade \
--network=appnamenetwork \
postgres:17

sudo docker run --cpus=".8" -it --rm --user root \
-e PGPASSWORD=appname_pgpassword \
--name appname-postgres-upgrade-dumpall \
--network=appnamenetwork \
postgres:17 bash

# pg_dumpall -h appname-postgres -p 5432 -U appname_pguser | psql -d postgres -h appname-postgres-upgrade -p 5432 -U appname_pguser