Postgresql backup and restore with Powershell

Hi,

I am trying to backup and restore my running Postgres 9.6 DB container using Powershell.
I am able to get the backup working
docker exec -u postgres postgres_postgresdb_1 pg_dump -Fc mydb > mydb_0.1.0.dmp
But when trying to restore
docker exec -u postgres postgres_postgres_1 pg_restore -C -d postgres < mydb_0.1.0.dmp

I get the error message from Powershell that ‘<’ isn’t a supported operator

The ‘<’ operator is reserved for future use.
+ CategoryInfo : ParserError: (: ) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RedirectionNotSupported

So I tried to pipe it with get-content instead
Get-Content mydb_0.1.0.dmp | docker exec -u postgres postgres_postgres_1 pg_restore -C -d postgres

But it gets stuck and does nothing…
Anybody was able to do that on Windows?

The problem is that your command (that you want run in the linux container) is interpreted by powershell. Either use an interactive exec (docker exec -ti) or try to place double quotes around the command you want to run in the exec session.