This commit is contained in:
@@ -56,9 +56,9 @@ namespace AyaNova.Biz
|
|||||||
//this is valid:
|
//this is valid:
|
||||||
//C:\data\code\PostgreSQLPortable_12.0\App\PgSQL\bin\pg_dump --dbname=postgresql://postgres:raven@127.0.0.1:5432/AyaNova -Fc > huge_new.backup
|
//C:\data\code\PostgreSQLPortable_12.0\App\PgSQL\bin\pg_dump --dbname=postgresql://postgres:raven@127.0.0.1:5432/AyaNova -Fc > huge_new.backup
|
||||||
//"AYANOVA_DB_CONNECTION": "Server=localhost;Username=postgres;Password=raven;Database=AyaNova;",
|
//"AYANOVA_DB_CONNECTION": "Server=localhost;Username=postgres;Password=raven;Database=AyaNova;",
|
||||||
|
|
||||||
Npgsql.NpgsqlConnectionStringBuilder PostgresConnectionString=new Npgsql.NpgsqlConnectionStringBuilder(ServerBootConfig.AYANOVA_DB_CONNECTION);
|
Npgsql.NpgsqlConnectionStringBuilder PostgresConnectionString = new Npgsql.NpgsqlConnectionStringBuilder(ServerBootConfig.AYANOVA_DB_CONNECTION);
|
||||||
var DBNameParameter=$"--dbname=postgresql://{PostgresConnectionString.Username}:{PostgresConnectionString.Password}@{PostgresConnectionString.Host}:{PostgresConnectionString.Port}/{PostgresConnectionString.Database}";
|
var DBNameParameter = $"--dbname=postgresql://{PostgresConnectionString.Username}:{PostgresConnectionString.Password}@{PostgresConnectionString.Host}:{PostgresConnectionString.Port}/{PostgresConnectionString.Database}";
|
||||||
|
|
||||||
var DataBackupFile = $"db-{FileUtil.GetSafeDateFileName()}.backup";//presentation issue so don't use UTC for this one
|
var DataBackupFile = $"db-{FileUtil.GetSafeDateFileName()}.backup";//presentation issue so don't use UTC for this one
|
||||||
DataBackupFile = FileUtil.GetFullPathForUtilityFile(DataBackupFile);
|
DataBackupFile = FileUtil.GetFullPathForUtilityFile(DataBackupFile);
|
||||||
@@ -67,7 +67,7 @@ namespace AyaNova.Biz
|
|||||||
if (!string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH))
|
if (!string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH))
|
||||||
BackupUtilityCommand = Path.Combine(ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH, BackupUtilityCommand);
|
BackupUtilityCommand = Path.Combine(ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH, BackupUtilityCommand);
|
||||||
|
|
||||||
var Arguments=$"{BackupUtilityCommand} {DBNameParameter} -Fc > {DataBackupFile}";
|
var Arguments = $"{BackupUtilityCommand} {DBNameParameter} -Fc > {DataBackupFile}";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ namespace AyaNova.Biz
|
|||||||
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);
|
var Result = RunProgram.Run(BackupUtilityCommand, Arguments, log);
|
||||||
log.LogInformation($"BACKUP RESULT: {Result}");
|
log.LogInformation($"BACKUP RESULT: {Result}");
|
||||||
|
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
apiServerState.ResumePriorState();
|
apiServerState.ResumePriorState();
|
||||||
BackupIsRunning = false;
|
BackupIsRunning = false;
|
||||||
log.LogInformation("BACKUP STUB: COMPLETELY FINISHED BACKING UP");
|
log.LogInformation("BACKUP STUB: COMPLETELY FINISHED BACKING UP");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace AyaNova.Util
|
namespace AyaNova.Util
|
||||||
{
|
{
|
||||||
@@ -8,25 +9,38 @@ namespace AyaNova.Util
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public static string Run(string cmd, string arguments)
|
public static string Run(string cmd, string arguments, ILogger log = null)
|
||||||
{
|
{
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
try
|
||||||
{
|
{
|
||||||
return RunWindows(cmd, arguments);
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
}
|
{
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
return RunWindows(cmd, arguments);
|
||||||
{
|
}
|
||||||
return RunOSX(cmd, arguments);
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
|
{
|
||||||
|
return RunOSX(cmd, arguments);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
{
|
||||||
|
return RunLinuxBash(cmd, arguments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return RunLinuxBash(cmd, arguments);
|
if (log != null)
|
||||||
}
|
{
|
||||||
else
|
log.LogError(ex, $"RunProgram error running command:{cmd} {arguments}");
|
||||||
{
|
}
|
||||||
throw new PlatformNotSupportedException();
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
throw new PlatformNotSupportedException();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user