diff --git a/server/AyaNova/generator/CoreJobBackup.cs b/server/AyaNova/generator/CoreJobBackup.cs index a1b933fc..efc96d08 100644 --- a/server/AyaNova/generator/CoreJobBackup.cs +++ b/server/AyaNova/generator/CoreJobBackup.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Logging; using AyaNova.Models; using AyaNova.Util; using System.IO; - +using System.Runtime.InteropServices; namespace AyaNova.Biz { @@ -71,11 +71,25 @@ namespace AyaNova.Biz DataBackupFile = FileUtil.GetFullPathForBackupFile(DataBackupFile); var BackupUtilityCommand = "pg_dump"; - + if (!string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH)) BackupUtilityCommand = Path.Combine(ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH, BackupUtilityCommand); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + //put quotes around paths if spaces in them + if (BackupUtilityCommand.Contains(' ')) + { + BackupUtilityCommand = $"\"{BackupUtilityCommand}\""; + } + + if (DataBackupFile.Contains(' ')) + { + DataBackupFile = $"\"{DataBackupFile}\""; + } + } + var Arguments = $"{DBNameParameter} -Fc > {DataBackupFile}"; var Result = RunProgram.Run(BackupUtilityCommand, Arguments, log, MAXIMUM_MS_ALLOWED_FOR_PROCESSING); @@ -87,14 +101,14 @@ namespace AyaNova.Biz await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, msg, "Backup"); } else - { + { log.LogDebug("Backup of database completed OK"); //DO FILE BACKUP IF ATTACHMENTS BACKED UP if (ServerGlobalOpsSettingsCache.Backup.BackupAttachments) { await JobsBiz.LogJobAsync(Guid.Empty, $"LT:Backup LT:Attachments"); - FileUtil.BackupAttachments(DemandFileNamePrepend); + FileUtil.BackupAttachments(DemandFileNamePrepend); log.LogDebug("Backup of file attachments completed OK"); } diff --git a/server/AyaNova/util/RunProgram.cs b/server/AyaNova/util/RunProgram.cs index b17a638b..a5b63367 100644 --- a/server/AyaNova/util/RunProgram.cs +++ b/server/AyaNova/util/RunProgram.cs @@ -52,8 +52,6 @@ namespace AyaNova.Util // var FullRunCommand=$"/C {BackupUtilityCommand} {Arguments}"; //for Windows need to pass to cmd.exe because often have command line piping etc - - //todo: make this work when there are spaces with quotes etc var args = $"/C {cmd} {arguments}"; using (var process = new Process()) {