From c948ade688faeef3b3b3ee4f63ea0d75a8598143 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Wed, 13 Mar 2024 17:03:23 +0000 Subject: [PATCH] fixed some curl refs --- backup.ps1 | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/backup.ps1 b/backup.ps1 index 655529e..b8cd970 100644 --- a/backup.ps1 +++ b/backup.ps1 @@ -2,6 +2,16 @@ $dir = Split-Path $script:MyInvocation.MyCommand.Path . "$dir/env.ps1" +if ( $KUMA_ID -ne "" ){ + $RUNNING_URL = https://$KUMA_URL/api/push/$KUMA_ID?status=up"&"msg=Running"&"ping= + $FAILURE_URL = https://$KUMA_URL/api/push/$KUMA_ID?status=down"&"msg=Failed"&"ping= + $SUCCESS_URL = https://$KUMA_URL/api/push/$KUMA_ID?status=up"&"msg=Completed"&"ping= +} else if ( $HEALTHCHECK_UUID -ne "" ) { + $RUNNING_URL = https://hc-ping.com/$HEALTHCHECK_UUID/start + $FAILURE_URL = https://hc-ping.com/$HEALTHCHECK_UUID/fail + $SUCCESS_URL = https://hc-ping.com/$HEALTHCHECK_UUID +} +Write-Host $URL $DATE = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss") Write-Host "Backup $NAME at $DATE" $BACKUP_CMD="restic backup $BACKUP_DIR" @@ -16,21 +26,11 @@ $running = get-process | ?{$_.path -eq "C:\Windows\system32\restic.exe"} Write-Host $running if ( $running ) { Write-Host "Backup already running; $running. Exiting..." - if ( $KUMA_ID -ne "" ){ - ./bin/curl.exe https://$KUMA_URL/api/push/$KUMA_ID?status=down"&"msg=Failed"&"ping= - } - if ( $HEALTHCHECK_UUID -ne "" ) { - ./bin/curl.exe https://hc-ping.com/$HEALTHCHECK_UUID/fail - } + ./bin/curl.exe $FAILURE_URL exit } Write-Host "Not currently running. Continuing..." -if ( $KUMA_ID -ne "" ){ - ./bin/curl.exe https://$KUMA_URL/api/push/$KUMA_ID?status=up"&"msg=Running"&"ping= -} -if ( $HEALTHCHECK_UUID -ne "" ) { - ./bin/curl.exe https://hc-ping.com/$HEALTHCHECK_UUID/start -} +./bin/curl.exe $RUNNING_URL if ( $PRE_RUN_SCRIPT ) { . $dir/$PRE_RUN_SCRIPT } @@ -39,17 +39,7 @@ if ( $LastExitCode -eq 0 ) { if ( $POST_RUN_SCRIPT ) { . $dir/$POST_RUN_SCRIPT } - if ( $KUMA_ID -ne "" ){ - ./bin/curl.exe https://$KUMA_URL/api/push/$KUMA_ID?status=up"&"msg=Completed"&"ping= - } - if ( $HEALTHCHECK_UUID -ne "" ) { - ./bin/curl.exe https://hc-ping.com/$HEALTHCHECK_UUID - } + ./bin/curl.exe $SUCCESS_URL } else { - if ( $KUMA_ID -ne "" ){ - ./bin/curl.exe https://$KUMA_URL/api/push/$KUMA_ID?status=down"&"msg=Failed"&"ping= - } - if ( $HEALTHCHECK_UUID -ne "" ) { - ./bin/curl.exe https://hc-ping.com/$HEALTHCHECK_UUID/fail - } + ./bin/curl.exe $FAILURE_URL }