1

I need to import a old db into a new postgre server.

Is there a way to migrate an old database to a new server without using pg_dump?

I don't have the sql file, or the old server backup file, neither the user and the password, just the physical files in the "\data" folder, is there any way to do this?

The target server is in the same version of th old server.

Thanks.

4
  • 1
    The old server and target server on same OS and version? Commented Aug 1, 2020 at 22:52
  • Yes, same os, same server version Commented Aug 2, 2020 at 14:56
  • What OS are you using? Commented Aug 2, 2020 at 15:27
  • its a windows 10 server Commented Aug 2, 2020 at 22:36

1 Answer 1

1

Well as a test you could try:

pg_ctl start -D $DATA

Where pg_ctl comes from the target version and the $DATA is the the /data directory. You have not said how you came to have just a /data directory. If this came from an unclean shutdown or a corrupted drive the possibility exists that the server will not start.

UPDATE

To get around auth failure find pg_hba.conf and create or modify local connection to use trust method. For more info see pg_hba and trust. Then you should be able to connect like:

psql -d some_db -U postgres

Once in you can use ALTER ROLE to change password:

ALTER ROLE <role_name> WITH PASSWORD 'new_password';

Sign up to request clarification or add additional context in comments.

5 Comments

Start works, but no connection, auth fail.. I dont have the passwrd for the old server
Almost done, server starts ok, but my server is in a windows s'o, when i try to use the psql.exe, its say: FATAL role "postgres" does not exist. Even in TRUST mode
That is not because it is on Windows, it is because the instance you are starting does not have a postgres role/user. Do you know what users/roles where in this instance? Maybe take a look in pg_hba.conf to see if there any user names mentioned?
I look the file, there is nothing, im totally fckd up :(. Its time to cry... But, thank you a lot man.
Are you talking about pg_hba.conf file? It may not be over yet. Go here postgres and under Notes look at Single-User Mode. This gets you in as superuser without specifying a user name.

Your Answer

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.