When pg_restore --clean --dbname=my_database backup_file.sql to restore a database dump to an empty database, recovery is successful, but with the following warning message:
pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore: [archiver (db)] Error from TOC entry 161; 1259 16549 TABLE example_table root pg_restore: [archiver (db)] could not execute query: ERROR: table "example_table" does not exist Command was: DROP TABLE public.example_table; WARNING: errors ignored on restore: 1
As you can see from the message, the restore is complete. There were errors, but pg_restore claims to have ignored them. I was also able to manually query the database to make sure that all the data that I expected to be in the dump was present in the database after recovery.
The problem is that the above command has the status 1, not 0. When the database execution is restored programmatically (as I intend to do, when I automate this process), this is problematic, since my script must be able to reliably determine whether it succeeded whether to recover or not.
Is there a way to make pg_restore ignore warnings when determining exit status? Or is there an alternative pg_restore method that I can use to get more accurate success / failure information? How can I restore the database and reliably determine programmatically whether I was able to recover?
Please note that I am currently using PostgreSQL 9.1.
Ajedi32
source share