HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

pg_dump without postgresql

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlwithoutpg_dump

Problem

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.

Solution

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


More about Pg_dump:

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

Code Snippets

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
yum install postgresql
pg_dump -h remote_address -U username -D dbname -Fp > backup.sql

Context

StackExchange Database Administrators Q#193023, answer score: 13

Revisions (0)

No revisions yet.