This commit is contained in:
@@ -70,21 +70,11 @@ namespace AyaNova.Biz
|
||||
|
||||
var Arguments = $"{DBNameParameter} -Fc > {DataBackupFile}";
|
||||
|
||||
var RunCommand=$"/C {BackupUtilityCommand} {Arguments}";
|
||||
|
||||
log.LogInformation("BACKUP STUB: DATA BACKUP RUNNING NOW - TORA TORA TORA!");
|
||||
//log.LogInformation($"CALLING BACKUP COMMAND: {BackupUtilityCommand} {Arguments}");
|
||||
|
||||
//RUN THE BACKUP
|
||||
//var Result = RunProgram.Run(BackupUtilityCommand, Arguments, log);
|
||||
List<string> args=new List<string>();
|
||||
args.Add(RunCommand);
|
||||
// args.Add("--dbname=postgresql://postgres:raven@127.0.0.1:5432/AyaNova");
|
||||
// args.Add("-Fc");
|
||||
// args.Add(">");
|
||||
// args.Add(DataBackupFile);
|
||||
var Result = RunProgram.Run("cmd.exe",args, log);
|
||||
log.LogInformation($"BACKUP RESULT: {Result}");
|
||||
var Result = RunProgram.Run(BackupUtilityCommand, Arguments, log);
|
||||
if (string.IsNullOrWhiteSpace(Result))
|
||||
log.LogDebug("BACKUP SUCCESSFUL (NO ERROR)");
|
||||
else
|
||||
log.LogInformation($"BACKUP ERROR: {Result}");
|
||||
|
||||
|
||||
//DO FILE BACKUP IF ATTACHMENTS BACKED UP
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace AyaNova.Util
|
||||
{
|
||||
|
||||
|
||||
public static string Run(string cmd, List<string> arguments, ILogger log = null)
|
||||
public static string Run(string cmd, string arguments, ILogger log = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -46,51 +46,26 @@ namespace AyaNova.Util
|
||||
|
||||
|
||||
|
||||
private static string RunWindows(string cmd, List<string> arguments)
|
||||
private static string RunWindows(string cmd, string arguments)
|
||||
{
|
||||
/*
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.OutputDataReceived += (sender, args) => Console.WriteLine("received output: {0}", args.Data);
|
||||
process.Start();
|
||||
process.BeginOutputReadLine();
|
||||
//RunProgram.Run("cmd.exe",FullRunCommand, log);
|
||||
// var FullRunCommand=$"/C {BackupUtilityCommand} {Arguments}";
|
||||
|
||||
*/
|
||||
// string result = string.Empty;
|
||||
// using (var process = new Process())
|
||||
// {
|
||||
// process.StartInfo = new ProcessStartInfo
|
||||
// {
|
||||
// FileName = cmd,
|
||||
// Arguments = arguments,
|
||||
// RedirectStandardOutput = true,
|
||||
// UseShellExecute = false,
|
||||
// CreateNoWindow = true,
|
||||
// };
|
||||
// process.OutputDataReceived += (sender, args) => result += args.Data;
|
||||
// process.Start();
|
||||
// // string result = process.StandardOutput.ReadToEnd();
|
||||
// // process.WaitForExit();
|
||||
// return result;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
//this executes but doesnt return error
|
||||
//for Windows need to pass to cmd.exe because often have command line piping etc
|
||||
var args=$"{cmd} {arguments}";
|
||||
using (var process = new Process())
|
||||
{
|
||||
process.StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = cmd,
|
||||
// Arguments = arguments,
|
||||
FileName = "cmd.exe /C",
|
||||
Arguments = args,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
};
|
||||
|
||||
|
||||
foreach (string s in arguments)
|
||||
process.StartInfo.ArgumentList.Add(s);
|
||||
process.Start();
|
||||
|
||||
string result = $"{process.StandardOutput.ReadToEnd()}{process.StandardError.ReadToEnd()} ";
|
||||
@@ -99,7 +74,7 @@ process.BeginOutputReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
private static string RunLinuxBash(string cmd, List<string> arguments)
|
||||
private static string RunLinuxBash(string cmd, string arguments)
|
||||
{
|
||||
var escapedArgs = $"{cmd} {arguments}".Replace("\"", "\\\"");
|
||||
|
||||
@@ -108,13 +83,11 @@ process.BeginOutputReadLine();
|
||||
process.StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "/bin/bash",
|
||||
// Arguments = $"-c \"{escapedArgs}\"",
|
||||
Arguments = $"-c \"{escapedArgs}\"",
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
};
|
||||
foreach (string s in arguments)
|
||||
process.StartInfo.ArgumentList.Add(s);
|
||||
|
||||
process.Start();
|
||||
string result = process.StandardOutput.ReadToEnd();
|
||||
@@ -124,21 +97,18 @@ process.BeginOutputReadLine();
|
||||
}
|
||||
|
||||
|
||||
private static string RunOSX(string cmd, List<string> arguments)
|
||||
private static string RunOSX(string cmd, string arguments)
|
||||
{
|
||||
using (var process = new Process())
|
||||
{
|
||||
process.StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = cmd,
|
||||
|
||||
// Arguments = arguments,
|
||||
Arguments = arguments,
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
};
|
||||
foreach (string s in arguments)
|
||||
process.StartInfo.ArgumentList.Add(s);
|
||||
|
||||
process.Start();
|
||||
string result = process.StandardOutput.ReadToEnd();
|
||||
|
||||
Reference in New Issue
Block a user