Linces Marques
Linces Marques

Reputation: 684

Import/Export PostgreSQL db "without" pg_dump or sql file / backup, etc...?

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.

Upvotes: 0

Views: 1406

Answers (1)

Adrian Klaver
Adrian Klaver

Reputation: 19724

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';

Upvotes: 1

Related Questions