This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -50,7 +50,7 @@
|
|||||||
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
||||||
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
||||||
"AYANOVA_METRICS_USE_INFLUXDB": "false",
|
"AYANOVA_METRICS_USE_INFLUXDB": "false",
|
||||||
"AYANOVA_SERVER_TEST_MODE":"false",
|
"AYANOVA_SERVER_TEST_MODE":"true",
|
||||||
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL":"small",
|
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL":"small",
|
||||||
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET":"-7",
|
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET":"-7",
|
||||||
"AYANOVA_BACKUP_PG_DUMP_PATH":"C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\"
|
"AYANOVA_BACKUP_PG_DUMP_PATH":"C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using AyaNova.Models;
|
using AyaNova.Models;
|
||||||
@@ -69,14 +70,20 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
var Arguments = $"{DBNameParameter} -Fc > {DataBackupFile}";
|
var Arguments = $"{DBNameParameter} -Fc > {DataBackupFile}";
|
||||||
|
|
||||||
var RunCommand=$"\"{BackupUtilityCommand} {Arguments}\"";
|
var RunCommand=$"/C {BackupUtilityCommand} {Arguments}";
|
||||||
|
|
||||||
log.LogInformation("BACKUP STUB: DATA BACKUP RUNNING NOW - TORA TORA TORA!");
|
log.LogInformation("BACKUP STUB: DATA BACKUP RUNNING NOW - TORA TORA TORA!");
|
||||||
log.LogInformation($"CALLING BACKUP COMMAND: {BackupUtilityCommand} {Arguments}");
|
//log.LogInformation($"CALLING BACKUP COMMAND: {BackupUtilityCommand} {Arguments}");
|
||||||
|
|
||||||
//RUN THE BACKUP
|
//RUN THE BACKUP
|
||||||
//var Result = RunProgram.Run(BackupUtilityCommand, Arguments, log);
|
//var Result = RunProgram.Run(BackupUtilityCommand, Arguments, log);
|
||||||
var Result = RunProgram.Run(RunCommand,"", 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}");
|
log.LogInformation($"BACKUP RESULT: {Result}");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -9,7 +10,7 @@ namespace AyaNova.Util
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public static string Run(string cmd, string arguments, ILogger log = null)
|
public static string Run(string cmd, List<string> arguments, ILogger log = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -45,7 +46,7 @@ namespace AyaNova.Util
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static string RunWindows(string cmd, string arguments)
|
private static string RunWindows(string cmd, List<string> arguments)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
process.StartInfo.UseShellExecute = false;
|
process.StartInfo.UseShellExecute = false;
|
||||||
@@ -81,13 +82,15 @@ process.BeginOutputReadLine();
|
|||||||
process.StartInfo = new ProcessStartInfo
|
process.StartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = cmd,
|
FileName = cmd,
|
||||||
Arguments = arguments,
|
// Arguments = arguments,
|
||||||
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()} ";
|
||||||
@@ -96,7 +99,7 @@ process.BeginOutputReadLine();
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string RunLinuxBash(string cmd, string arguments)
|
private static string RunLinuxBash(string cmd, List<string> arguments)
|
||||||
{
|
{
|
||||||
var escapedArgs = $"{cmd} {arguments}".Replace("\"", "\\\"");
|
var escapedArgs = $"{cmd} {arguments}".Replace("\"", "\\\"");
|
||||||
|
|
||||||
@@ -105,11 +108,13 @@ 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();
|
||||||
@@ -119,18 +124,21 @@ process.BeginOutputReadLine();
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static string RunOSX(string cmd, string arguments)
|
private static string RunOSX(string cmd, List<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