Backing up Postgres with docker exec -t and redirecting to a file corrupts the dump: -t allocates a pseudo-TTY, which does line-ending translation and swaps every \n for \r\n.

# wrong: whole dump comes out as CRLF, may restore badly
docker exec -t pg pg_dump -U postgres db > dump.sql

# right: no -t
docker exec pg pg_dump -U postgres db > dump.sql

-t only makes sense when you want an interactive terminal. To capture output to a file or pipe, always drop it. Check with file dump.sql — it should say “ASCII text”, not “ASCII text, with CRLF line terminators”.