To backup PostgreSQL database, run
pg_dump -h HOSTNMAME -p PORT -U USER -d DBNAME -W -f file.psql
Example
pg_dump -h ukgaa1vy7o672pj.caqdhl3x5dow.us-east-1.rds.amazonaws.com -p 5432 -U serveroku -d serverokdb -W -f file.psql
If you don’t have PostgreSQL installed, you can use docker, pull the appropriate version of docker image, in this case i used version 13.5, same version used by Amazon RDS, then run
docker run --rm -ti -e PGPASSWORD='PW_HERE' postgres:13.5 pg_dump -h serverok.ckdva7obgq6c.us-west-1.rds.amazonaws.com -U USER_HERE -d DB_NAME_HERE > backup.psql
It will prompt for the password, once you enter the password, the database will be backed up to file backup.psql
Leave a Reply