Home > Net >  gbak gives system directive access failed on Ubuntu when running from net core application
gbak gives system directive access failed on Ubuntu when running from net core application

Time:03-08

Basically, I want to run a gbak restore (Firebird 3) from my ASP.NET Core application on Ubuntu.

Here is my code:

string output = "";

using (Process pProcess = new System.Diagnostics.Process())
{
    pProcess.StartInfo.FileName = "gbak";
    //pProcess.StartInfo.UseShellExecute = true;
    pProcess.StartInfo.RedirectStandardError = true;
    pProcess.StartInfo.Arguments = "-c  /home/database/backup.gbk /home/database/tempdb.fdb -user SYSDBA -pass masterkey -r";
               
    pProcess.StartInfo.CreateNoWindow = true;
             
    pProcess.Start();
    output = pProcess.StandardError.ReadToEnd();
    pProcess.WaitForExit();
}
return output;

This gives me an error:

gbak: ERROR:operating system directive access failed
gbak: ERROR:    Not a directory
gbak: ERROR:failed to create database /home/database/tempdb.fdb
gbak:Exiting before completion due to errors

If I execute the same command directly from the terminal, it works just fine:

gbak -c  /home/database/backup.gbk /home/database/tempdb.fdb -user SYSDBA -pass masterkey -r

Also I have tried with and without UseShellExecute and got the same result.

Any idea on what's going on?

CodePudding user response:

You are getting this message because you are trying to use Firebird engine in embedded mode without proper UID/GID set for the process.

You'd better to use Services API via remote connection. Look at this example: https://github.com/FirebirdSQL/NETProvider/blob/master/docs/services-backup.md

CodePudding user response:

problem solved !

as mentionned before my initial code was using the embedded version of firebird

here the correct way imo to do that with a bonus using the service_mgr wich is much much more faster :

pProcess.StartInfo.UseShellExecute = false;
pProcess.StartInfo.CreateNoWindow = true;
pProcess.StartInfo.FileName = "gbak";
pProcess.StartInfo.Arguments = "-se localhost:service_mgr -c  /home/database/backup.gbk /home/database/tempdb.fdb -user SYSDBA -pass masterkey";
  • Related