Home > database >  Incorrect characters after restore docker postgres database
Incorrect characters after restore docker postgres database

Time:10-12

backup makes by command

docker exec -t arcane-aio pg_dump arcane-aio -c -U admin > arcane_aio_db.sql

restore makes by command

cat arcane_aio_db.sql | docker exec -i arcane-aio psql -U admin -d arcane-aio

all good but all russian symbols are replaced by "?"

charfield value before restore "Привет, hi!"

charfield value after restore backup "??????, hi!"

I checked the encoding of the backup, db before backup, db after restore, they are the same (en_US.utf8 (maybe this encoding don't support russian language))

Edit

we use windows

after change of system encoding from (cyrilic) to utf8 values in data dump become correct

but after restore in database we still see "?" instead of russian symbols

CodePudding user response:

the cat command uses your shell character encoding.

Did you try running simply the first part:

cat arcane_aio_db.sql

I bet it also shows the ???.

You need to set the charset to the same encoding on both sides. You probably have UTF-8 on one side and some russian language on the other.

The pipe, that writes to file is binary and doesn't care about the encoding, but cat does.

You can check your encoding with

echo $LANG

make sure it is UTF-8 on both sides and that should fix your issue.

CodePudding user response:

Since a pg_dump includes instructions to set the client_encoding correctly, the data in your target database will be correct. That is, unless the database encoding is SQL_ASCII, in which case you are lost anyway if you need Cyrillic characters.

The problem must be with your client software or your terminal encoding.

  • Related