pg_dump Without PostgreSQL – How to Perform

postgresql

I have a server with Postgresql. I don't have access to this server, just the endpoint to connect with psql. I want to backup data from this server to another server using pg_dump. However, my second server does not have postgresql and I don't have root privilege to install it either.
Is there any way to run pg_dump without install postgresql?

It is possible to install postgresql on my client and pg_dump from it but I'm afraid the database is too big for my laptop.

Best Answer

Basically we don't need any Postgresql server to take the backup. Postgresql client is enough for this.

But you must have sudo privilege to install this client.

For Ubuntu:

echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" >>  /etc/apt/sources.list.d/pgdg.list
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-client

For RedHat/CentOS/Amazon Linux:

Download the rpm here: https://yum.postgresql.org/repopackages.php#pg96

yum install postgresql 

Dump the Database

pg_dump -h remote_address -U username -D dbname -Fp > backup.sql

enter image description here

More about Pg_dump:

https://www.postgresql.org/docs/9.6/static/app-pgdump.html