Question

I have a problem restoring a PostgreSQL DB which I have backup early using the following command:

pg_dump -i -h localhost -p 5432 -U Mark -F c -b -v -f "C:\Users\mchan\Desktop\MyDB\DBBackup.backup" mydb

Now When I try to restore this DB backup on (another machine) I got the following error:

pg_restore: [archiver] directory "C:\Users\mark\Desktop\MCHANBackups\DBBackup.backup" does not appear to be a valid archive ("toc.dat" does not exist)

Below is the command I used to restore the backup:

pg_restore -i -h localhost -p 5432 -U Mark -d mydb -v "C:\Users\mark\Desktop\MCHANBackups\DBBackup.backup"

Can someone please help me and tell me what I am doing wrong here?

Was it helpful?

Solution

I think you have used custom format and the backup is sent to normal text file. For restoring from text files, use psql command: psql -e -d template1 -f "C:\Users\mchan\Desktop\MyDB\DBBackup.backup" Refer to this post on Postgresql's Community page.

Use the psql command as follows:

psql -e -U username -d databaseName -f "C:\Users\mchan\Desktop\MyDB\DBBackup.backup"

Username should be a role defined in the database. Ex: postgres

If the psql command prompts for a password and you don't know the password for the user, replace "md5" with "trust" in pg_hba.conf file under "/data" folder and restart "postgres service" for this change to take effect.

Once this change is done psql will not prompt for the password.

For more documentation on psql and additional options , refer to psql-doc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top