PostgreSQL – Can’t Restore Distribution DB Backup into Staging DB

postgresqlpostgresql-9.2postgresql-9.3windows-server

I keep getting this pg_restore: [archiver] did not find magic string in file header when i execute a pg_restore -Fc -U "username" -d "dbname" "filename".dmpon my staging DB.

These DB are running on two separate AWS instances with windows server 2008 for both environments(staging and distribution). The postgres version used on distribution is the 9.2 and the version on staging is 9.3.

I think this issue could be related to the fact that i get several pg_dump: [custom archiver] WARNING: ftell mismatch with expected position -- ftell used warnings when i execute a pg_dump -Fc -U "username" -w "dbname" > "filename".dmp on the distribution DB.

Any help is appreciated.

Best Answer

I found several bug reports indicating that pg_dump has problems writing to a pipe on Windows:

Instead of writing to stdout and redirecting to a file, try using -f specify the output file:

pg_dump -Fc -U "username" -w "dbname" -f "filename".dmp