Johnathan Mackney
Johnathan Mackney

Reputation: 545

Restoring New Postgres Database with Old Data Directory

I have not made a backup from my old data directory, but I still have the directory in tact. In my current database I have the same Schema, etc... When I try to restore the database (using pgadmin III), I receive this error:

/Applications/pgAdmin3.app/Contents/SharedSupport/pg_restore --host localhost -- port 5432 -- username "postgres" --dbname "postgres" --role "postgres" --no-password --format directory --verbose "/Library/Postgres/9.5/data" 
pg_restore: [directory archiver] could not open input file "/Library/PostgreSQL/9.5/data/toc.dat": No such file or directory

I am not sure where the toc.dat came into play, as I am not familiar with it. This is evidently halting the restore, but I do not know how to fix that issue.

Upvotes: 2

Views: 8984

Answers (2)

Zeeng
Zeeng

Reputation: 1235

Using 3.0 version of pgAdmin 4

Might be too late, but this works for me all the time.

From the Current or Old database

  1. Launch pgAdmin;
  2. Expand Servers and login therein;
  3. Expand PostgreSQL, and then click the name of the database that you want to export/Backup;
  4. Right click on it for options and select Backup...;
  5. On the opened window, Enter a suitable filename and make sure format is set to Tar from the drop-down menu;
  6. Then Click Backup on the bottom;

Once the Backup file is saved

On the New or Other database(Or on a different machine)

Create a new database and right click on it once created, select Restore... option and locate the Backup up file created earlier. You might have to have select

Show hidden files and folders option and set Format to All Files

That error should not be experienced with this method.

Upvotes: 1

Awais Rafique
Awais Rafique

Reputation: 476

while restoring don't use --format in arguments.

Upvotes: 1

Related Questions