This commit is contained in:
@@ -70,21 +70,11 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
var Arguments = $"{DBNameParameter} -Fc > {DataBackupFile}";
|
var Arguments = $"{DBNameParameter} -Fc > {DataBackupFile}";
|
||||||
|
|
||||||
var RunCommand=$"/C {BackupUtilityCommand} {Arguments}";
|
var Result = RunProgram.Run(BackupUtilityCommand, Arguments, log);
|
||||||
|
if (string.IsNullOrWhiteSpace(Result))
|
||||||
log.LogInformation("BACKUP STUB: DATA BACKUP RUNNING NOW - TORA TORA TORA!");
|
log.LogDebug("BACKUP SUCCESSFUL (NO ERROR)");
|
||||||
//log.LogInformation($"CALLING BACKUP COMMAND: {BackupUtilityCommand} {Arguments}");
|
else
|
||||||
|
log.LogInformation($"BACKUP ERROR: {Result}");
|
||||||
//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}");
|
|
||||||
|
|
||||||
|
|
||||||
//DO FILE BACKUP IF ATTACHMENTS BACKED UP
|
//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
|
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)
|
||||||
{
|
{
|
||||||
/*
|
//RunProgram.Run("cmd.exe",FullRunCommand, log);
|
||||||
process.StartInfo.UseShellExecute = false;
|
// var FullRunCommand=$"/C {BackupUtilityCommand} {Arguments}";
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
|
||||||
process.OutputDataReceived += (sender, args) => Console.WriteLine("received output: {0}", args.Data);
|
|
||||||
process.Start();
|
|
||||||
process.BeginOutputReadLine();
|
|
||||||
|
|
||||||
*/
|
//for Windows need to pass to cmd.exe because often have command line piping etc
|
||||||
// string result = string.Empty;
|
var args=$"{cmd} {arguments}";
|
||||||
// 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
|
|
||||||
using (var process = new Process())
|
using (var process = new Process())
|
||||||
{
|
{
|
||||||
process.StartInfo = new ProcessStartInfo
|
process.StartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = cmd,
|
FileName = "cmd.exe /C",
|
||||||
// Arguments = arguments,
|
Arguments = args,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
RedirectStandardError = true,
|
RedirectStandardError = true,
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
foreach (string s in arguments)
|
|
||||||
process.StartInfo.ArgumentList.Add(s);
|
|
||||||
process.Start();
|
process.Start();
|
||||||
|
|
||||||
string result = $"{process.StandardOutput.ReadToEnd()}{process.StandardError.ReadToEnd()} ";
|
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("\"", "\\\"");
|
var escapedArgs = $"{cmd} {arguments}".Replace("\"", "\\\"");
|
||||||
|
|
||||||
@@ -108,13 +83,11 @@ process.BeginOutputReadLine();
|
|||||||
process.StartInfo = new ProcessStartInfo
|
process.StartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = "/bin/bash",
|
FileName = "/bin/bash",
|
||||||
// Arguments = $"-c \"{escapedArgs}\"",
|
Arguments = $"-c \"{escapedArgs}\"",
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
};
|
};
|
||||||
foreach (string s in arguments)
|
|
||||||
process.StartInfo.ArgumentList.Add(s);
|
|
||||||
|
|
||||||
process.Start();
|
process.Start();
|
||||||
string result = process.StandardOutput.ReadToEnd();
|
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())
|
using (var process = new Process())
|
||||||
{
|
{
|
||||||
process.StartInfo = new ProcessStartInfo
|
process.StartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = cmd,
|
FileName = cmd,
|
||||||
|
Arguments = arguments,
|
||||||
// Arguments = arguments,
|
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
};
|
};
|
||||||
foreach (string s in arguments)
|
|
||||||
process.StartInfo.ArgumentList.Add(s);
|
|
||||||
|
|
||||||
process.Start();
|
process.Start();
|
||||||
string result = process.StandardOutput.ReadToEnd();
|
string result = process.StandardOutput.ReadToEnd();
|
||||||
|
|||||||
Reference in New Issue
Block a user