This is a very urgent situation.

We have a postgres 9.4 database installed on a CentOs machine.

We are trying to take a backup from a Heroku Postgres database and restore it to the database on CentOs machine.

The commands we are using: pg_dump -Fc -h ec2-99-99-99-99.compute-1.amazonaws.com -p 5762 -U xyz -d dbname > file.dump

The dump created by pg_dump seems to be missing data from columns that have the type of binary (these columns contain images in binary format).

When we restore this backup to the database on CentOS using following command, all the images from the image i.e. binary type columns are missing:

pg_restore -d onlinedb ~/file.dump

We have to go live in the morning and are completely bummed by this unexpected issue.

Output of \d attachments (attachments is the problem table) command:

             Table "public.attachments"
      Column      |          Type          | Modifiers 
 id               | integer                | not null
 configuration_id | integer                | 
 style            | character varying(255) | 
 file_contents    | bytea                  | 

More information: The heroku postgres database from which we are creating backup is PostgreSQL 9.2.6. The one we are restoring to is PostgreSQL 9.4.

  • 1
    Very urgent situation -> consider postgresql.org/support/professional_support Jan 5, 2015 at 2:38
  • There's no "binary" type, do you mean bytea ? Show the schema - output from psql's \d command on one of the problem tables. Then show the output of pg_restore -t the_table_name --schema-only. Jan 5, 2015 at 2:41
  • er, I meant \d tablename on one of the tables with binary data that's causing you problems. Jan 5, 2015 at 2:44
  • X-posted to dba.stackexchange.com/q/87529/7788 . Tip: Commenters don't get notified about edits to posts, but do get notified if you comment. Jan 5, 2015 at 4:02
  • OK, the other part? Output of pg_restore -t the_table_name (I think that syntax is right). Also, which pg_dump and pg_restore versions are you using? Jan 5, 2015 at 4:03

1 Answer 1


We finally were able to restore the backup. We tried so many things that I am not sure what the fix was, but our conclusion is that the problem was the bytea_output setting in postgresql.conf. We think Heroku was using value of 'escape' while our database server was using 'hex' and this caused the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.