Search code examples
postgresqlencodingpgadminpg-dumppg-restore

How does the pgadmin encodes the file path in backups?


I'm trying to restore dump files from locations that contain character from other languages besides English.

So here is what I did:

From inside the pgadmin I used the backup tool like:

enter image description here

And inside the FileName input provided an actual real folder named "א":

C:\א\toc.dump

enter image description here

The actual file argument (-f file) has been auto decoded into:

enter image description here pg_dump.exe --file "C:\\0F04~1\\TOC~1.DUM"

My question is what is the decoding system pgadmin uses in order to decode the file path argument?

How did it came up with 0F04~1 from א?

I'm asking it because pg_restore is not supporting file path that contains not English chars (from cmd):

pg_dump.exe --file "C:\\0F04~1\\TOC1.DUMP" .... WORKS OK!

pg_dump.exe --file "C:\\א\\TOC1.DUMP" ... Not Working!

pg_restore: [custom archiver] could not open input file "..."

As in this question, so if I'll find the encoding system for pgadmin I'll use it from code.

My goal is to encode the path that contain not-English chars from a batch code so it will work.


Solution

  • This is not something weird pgadmin does, but rather it is something weird Windows itself does when needing to represent such file names in a DOS-like setting. Like when the name is more than 8 chars, or extension more than 3.

    In my hands the weird presentation is only there in the logs and status messages. If I use the GUI file chooser, the file names look normal, and replay successfully.

    If you really want to know what Windows is doing, I think that is a better question for superuser with a Windows tag. I don't know why you can't restore these files. Are you using the pgAdmin GUI file chooser or trying to type the names in directly to something?