Postgresql – Error using pg_restore

pg-dumppg-restorepostgresql

I am using the following guide to migrate a database from my Windows 10 machine to my Managed Database on Digital Ocean.
https://www.digitalocean.com/docs/databases/postgresql/how-to/import-databases/

Unfortunately, I am having some issues restoring my database from local to the remote server. I am using the following command to perform my local dump:

pg_dump -U username -Fc dbname > filelocation.pgsql

This prompts for my password. Upon entering the password, pg_dump executes, and I am greeted with the following warning multiple times:

pg_dump: [custom archiver] WARNING: ftell mismatch with expected position -- ftell used

Following this, I attempt the pg_restore using the following command:

pg_restore -d 'my_connection_URI' filelocation.pgsql

However, I am greeted by the error:

pg_restore: [archiver] input file does not appear to be a valid archive

I believe that by specifying -Fc it should be a valid archive, so I can only presume that it has something to with the warnings I received, although I can't be sure.

Does anyone have any ideas of how to fix this?

Best Answer

Ok, looks like I had to get rid of the pipe. Using the following pg_dump command worked for me:

pg_dump -U username --format=c --file=filelocation.sqlc dbname