I'm trying to run pg_upgrade on Windows 2008R2, but I'm getting the error:
cannot write to log file pg_upgrade_internal.log Failure, exiting
I saw a similar question for Linux at 23216734 which explains that the issue is with permissions, but it doesn't help with Windows as I do not have a user named postgres
Same goes for the pg_upgrade docs, which mention a postgres
user:
RUNAS /USER:postgres "CMD.EXE"
But again, I do not have such a user, and am trying to run this command as Administrator so I don't understand why I would have no permission. I even tried to do
RUNAS /USER:Administrator "CMD.EXE"
And run pg_upgrade in the new command prompt, but am getting the same error.
Also, I am not sure which directory needs permissions? Where is the process trying to write pg_upgrade_internal.log
to?
More details:
The command I'm running is:
C:\Apps\postgresql\pgsql-9.5.0\bin>pg_upgrade.exe --old-datadir=E:\PGSQL_data --new-datadir=E:\PGSQLData\pgsql-9.5 --old-bindir=C:\Apps\postgresql\pgsql-9.4.5.3\bin --new-bindir=C:\Apps\postgresql\pgsql-9.5.0\bin
From the same command prompt that gives the error I ran the following commands and they all worked, creating an empty file in the respective directories, so write permissions to the directories that are passed to pg_upgrade are allowed:
C:\Apps\postgresql\pgsql-9.5.0\bin>type nul > E:\PGSQL_data\_test_write_permission.txt
C:\Apps\postgresql\pgsql-9.5.0\bin>type nul > E:\PGSQLData\pgsql-9.5\_test_write_permission.txt
C:\Apps\postgresql\pgsql-9.5.0\bin>type nul > C:\Apps\postgresql\pgsql-9.4.5.3\bin\_test_write_permission.txt
C:\Apps\postgresql\pgsql-9.5.0\bin>type nul > C:\Apps\postgresql\pgsql-9.5.0\bin\_test_write_permission.txt
So now I'm even more puzzled than before...
Even more details:
I see that the command to create the internal log file is at /src/bin/pg_upgrade/option.c#L101
Which calls fopen_priv(INTERNAL_LOG_FILE, "a")
defined at
/src/bin/pg_upgrade/file.c#L243
But I'm not sure to which directory it is trying to write. If I would know that then I can check the permissions on that directory.
Any ideas?
So the source code comment at /src/bin/pg_upgrade/file.c#L243 /* fopen() file with no group/other permissions */
gave me an idea.
I created a temp folder at C:\temp and gave Write permissions to Everyone, and then ran pg_upgrade from that directory, i.e.
C:\temp>C:\Apps\postgresql\pgsql-9.5.0\bin\pg_upgrade.exe --old-datadir=E:\PGSQL_data --new-datadir=E:\PGSQLData\pgsql-9.5 --old-bindir=C:\Apps\postgresql\pgsql-9.4.5.3\bin --new-bindir=C:\Apps\postgresql\pgsql-9.5.0\bin
Whereas before I was trying to run pg_upgrade from the working directory %PGSQL%\bin
which did not have a Write permissions to Everyone.
Now I don't get the cannot write to log file pg_upgrade_internal.log
error anymore.
The docs actually say pg_upgrade requires write permission in the current directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With