I am trying to create a backup of a database using pg_dump
. The database name has non ASCII characters, for example 本物ではないデータベース名.
I am making the following call:
pg_dump.exe --file="C:\Users\AUser\AppData\Local\Temp\本物ではないデータベース名_20150309185239.pgbak" pg_backupc4c978f4aebc4153adcabab6e097c347
However it is failing with the following error:
pg_dump: [archiver] could not open output file "C:\Users\AUser\AppData\Local\Temp\????????????_20150309185239.pgbak": Invalid argument
What I don't understand is that other commands work with non ASCII characters. For example mdkdir 本物ではないデータベース名
works fine.
Is this a bug in pg_dump
or am I doing something wrong?
UPDATE
As per @Mike Sherrill 'Cat Recall' in the comments, I tested redirection and it worked in both Powershell and the standard command line.
However, I then tried to automate this with C# and when I try to run the commands above using a C# Process
it fails:
ProcessStartInfo psi = new ProcessStartInfo(command, args);
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
psi.RedirectStandardOutput = psi.RedirectStandardError = true;
using (Process process = new Process())
{
process.StartInfo = psi;
string s = "";
process.ErrorDataReceived += delegate (object sender, DataReceivedEventArgs e)
{
s += e.Data;
};
string s1 = "";
process.OutputDataReceived += delegate (object sender, DataReceivedEventArgs e)
{
s1 += e.Data;
};
process.Start();
process.BeginErrorReadLine();
process.BeginOutputReadLine();
TimeSpan maxTime = TimeSpan.FromMinutes(10);
if (!process.WaitForExit((int)maxTime.TotalMilliseconds))
{
throw new Exception("Command " + command + " " + args + " Timed out after " + maxTime.TotalSeconds);
}
if (process.ExitCode != 0)
{
throw new Exception("Command " + command + " " + args + " failed with " + s + " " + s1);
}
}
Again, I can make a C# Process
and call mkdir
with Japanese letters and everything works.