9

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.

asked Dec 13, 2017 at 16:11
1
  • 1
    if you install on your client you can still direct the dump save to a different server as long as you have write permissions Commented Dec 13, 2017 at 16:18

4 Answers 4

14

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

answered Dec 13, 2017 at 16:18
4

For Windows

Just download the version you need here

It is not necessary to extract all data from the archive, it takes up a lot of space. It will be enough to unzip the \pgsql\bin directory, it will contain pg_dump.exe

To connect to a remote host use the --host parameter

Also, to simplify the work with pg_dump, I recommend adding the unzipped bin directory to the PATH environment variable. You can see how to do this here.

answered Sep 15, 2020 at 9:08
2

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.

Sure, pg_dump is just a program. You can download it or build it seperate from the others, also check out the -c option to --format=format if space is an issue

c custom Output a custom-format archive suitable for input into pg_restore. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.

answered Dec 13, 2017 at 16:19
0

I want to backup data from this server to another server ... my second server does not have postgresql ...

What are you hoping to do with the data once you get it onto the new machine?

Clearly, you're not duplicating the database, because you have no DBMS on the new machine to run it. Therefore, a backup of the database will be of limited use to you.

I think you need to talk to those responsible for this database and get their take on the best to achieve what you need - whatever that might be.

answered Sep 14, 2020 at 11:19
2
  • As always, before /storing/ any Data in any format, you should be asking how that data is going to be /used/! Commented Apr 2, 2024 at 10:05
  • Decommissioning a server means the Data has already been migrated to another server or you need to archive the Data for /possible/ use later. If that happens, it will be restored onto a database server of the same or a compatible, later version. Perfectly reasonable use cases but, in both instances, the "second server" /will/ have PostgreSQL on it, which you originally indicated was not the case. Just as long as they don't come back in six month's time saying "We want to load that old Data into Oracle"). Commented Apr 3, 2024 at 13:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.