This commit is contained in:
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Util;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace AyaNova.Biz
|
||||
@@ -51,16 +52,33 @@ namespace AyaNova.Biz
|
||||
//*************
|
||||
|
||||
//DO DATA BACKUP
|
||||
|
||||
var DataBackupFileName=$"db-{FileUtil.GetSafeDateFileName()}.backup";//presentation issue so don't use UTC for this one
|
||||
//build command
|
||||
//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
|
||||
//"AYANOVA_DB_CONNECTION": "Server=localhost;Username=postgres;Password=raven;Database=AyaNova;",
|
||||
|
||||
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 DataBackupFile = $"db-{FileUtil.GetSafeDateFileName()}.backup";//presentation issue so don't use UTC for this one
|
||||
DataBackupFile = FileUtil.GetFullPathForUtilityFile(DataBackupFile);
|
||||
|
||||
var BackupUtilityCommand = "pg_dump";
|
||||
if (!string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH))
|
||||
BackupUtilityCommand = Path.Combine(ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH, BackupUtilityCommand);
|
||||
|
||||
var FullBackupCommand=$"{BackupUtilityCommand} {DBNameParameter} -Fc > {DataBackupFile}";
|
||||
|
||||
|
||||
|
||||
log.LogInformation("BACKUP STUB: DATA BACKUP RUNNING NOW - TORA TORA TORA!");
|
||||
log.LogInformation($"dbdump path: {ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH}");
|
||||
log.LogInformation($"BACKUP COMMAND: {FullBackupCommand}");
|
||||
|
||||
//DO FILE BACKUP IF ATTACHMENTS BACKED UP
|
||||
log.LogInformation("BACKUP STUB: ATTACHMENTS BACKUP RUNNING NOW");
|
||||
log.LogInformation("BACKUP STUB: ATTACHMENTS BACKUP RUNNING NOW");
|
||||
|
||||
//PRUNE BACKUP SETS NOT KEPT
|
||||
log.LogInformation("BACKUP STUB: PRUNING RUNNING NOW");
|
||||
log.LogInformation("BACKUP STUB: PRUNING RUNNING NOW");
|
||||
|
||||
|
||||
//v.next - COPY TO ONLINE STORAGE
|
||||
@@ -84,6 +102,8 @@ namespace AyaNova.Biz
|
||||
{
|
||||
apiServerState.ResumePriorState();
|
||||
BackupIsRunning = false;
|
||||
log.LogInformation("BACKUP STUB: COMPLETELY FINISHED BACKING UP");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user