I dont have a lot of experience with Postgres, so I'm having a bit of a trouble accessing a database I just rescued from a broken Ubuntu server.
What I'm trying to do: The server that was sporting postgres is dead now, I can only access it via "rescue mod" provided by the hosting company. I tried chroot
in order to dump the database using pg_dump
or pg_dumpall
, but it seems that the server is unreachable in this way. The dump attempts to enroute himself via rescue.ovh.net
(OVH being the hosting provider), even if I specify -h localhost
.
So I came with a different idea: copying the whole Postgres folder into a local machine, and then dumping the database and keep on restoring everything starting from this dump. This is something you can do in MySQL, so I thought that this maybe would be possible with Postgres.
But so far it is not workin. I copied /var/lib/postgres
folder to my local machine (taking care that the owner in my local machine is also the postgres
user), but when I try to dump a database, I can't really do it.
The errors vary on the command:
My first attempt is to dump the database using the database user:
$ pg_dump -U discourse -h localhost > discourse_prod.sql
Password:
pg_dump: [archiver (db)] connection to database "discourse" failed: fe_sendauth: no password supplied
The prompt asks for a password, the user did not have a password, but If i just press enter
it aches and says no password provided.
My second attempt was dumping via postgres admin user:
sudo pg_dump -U postgres discourse_prod > ~/test.sql
I get a pg_dump: [archiver (db)] connection to database "discourse_prod" failed: FATAL: Peer authentication failed for user "postgres"
. So I try to switch user before trying to dump...
sudo -u postgres pg_dump -Fp discourse_prod > dump.sql
and now it seems that the database was not properly copied: pg_dump: [archiver (db)] connection to database "discourse_prod" failed: FATAL: database "discourse_prod" does not exist
As I said, I have not very much experience with Postgres, and I'm running out of ideas... on how to get a dump out from these files, i don't mind if I manage to get it from the devastated machine or from my locally copied files.
Any ideas?