September 4, 2020 · Don't Forget linux pgsql
Dumping and scp'ing a postgresql db
A need arose of transfering my hosting from AWS/RDS to yet-another-provider. And, while everything I have running there is a docker container (and therefore, easily transferable), I did hit an issue with dumping a pgsql database and limited disk space on the host. The solution? Dump, compress and transfer.
$ docker run -it --rm postgres pg_dump --username=<usr> --host=<hst> --dbname=postgresql://<usr>:<pwd>@<hst>/<database> | g
zip -c | ssh <other_hst> "cat - > <path_to>/<database>.sql.gz"