From f86cf27aa3cbfccf67d47f640b4ad0df64be09ae Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Aug 2023 19:39:59 +0200 Subject: backup-upload: detect failure creating config file --- backup-upload.rsc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/backup-upload.rsc b/backup-upload.rsc index 35b9b53..29bdfff 100644 --- a/backup-upload.rsc +++ b/backup-upload.rsc @@ -104,12 +104,19 @@ $WaitFullyConnected; /file/add name=($FilePath . ".conf") contents=$Config; $WaitForFile ($FilePath . ".conf"); - :do { - /tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".conf") \ - user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".conf"); - :set ConfigFile ($FileName . ".conf"); - } on-error={ - $LogPrintExit2 error $0 ("Uploading global-config-overlay failed!") false; + :local Size [ :len $Config ]; + :if ([ /file/get ($FilePath . ".conf") size ] = $Size) do={ + :do { + /tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".conf") \ + user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".conf"); + :set ConfigFile ($FileName . ".conf"); + } on-error={ + $LogPrintExit2 error $0 ("Uploading global-config-overlay failed!") false; + :set ConfigFile "failed"; + :set Failed 1; + } + } else={ + $LogPrintExit2 warning $0 ("Creating config file failed. Size should be " . $Size . " bytes, but is not.") false; :set ConfigFile "failed"; :set Failed 1; } -- cgit v1.2.3-70-g09d2