Set-Alias -Name curl -Value ./bin/curl.exe $dir = Split-Path $script:MyInvocation.MyCommand.Path . "$dir/env.ps1" $DATE = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss") Write-Host "Backup $NAME at $DATE" $BACKUP_CMD="restic backup $BACKUP_DIR" if ( $BACKUP_PARAMS ){ $BACKUP_CMD="$BACKUP_CMD $BACKUP_PARAMS" } if ( $BACKUP_EXCLUDE_FILE ) { $BACKUP_CMD="$BACKUP_CMD --exclude-file $dir/$BACKUP_EXCLUDE_FILE" } #Write-Host $BACKUP_CMD $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 "" ){ curl https://$KUMA_URL/api/push/$KUMA_ID?status=down"&"msg=Failed"&"ping= } if ( $HEALTHCHECK_UUID -ne "" ) { curl https://hc-ping.com/$HEALTHCHECK_UUID/fail } exit } Write-Host "Not currently running. Continuing..." if ( $KUMA_ID -ne "" ){ curl https://$KUMA_URL/api/push/$KUMA_ID?status=up"&"msg=Running"&"ping= } if ( $HEALTHCHECK_UUID -ne "" ) { curl https://hc-ping.com/$HEALTHCHECK_UUID/start } if ( $PRE_RUN_SCRIPT ) { . $dir/$PRE_RUN_SCRIPT } Invoke-Expression $BACKUP_CMD if ( $LastExitCode -eq 0 ) { if ( $POST_RUN_SCRIPT ) { . $dir/$POST_RUN_SCRIPT } if ( $KUMA_ID -ne "" ){ curl https://$KUMA_URL/api/push/$KUMA_ID?status=up"&"msg=Completed"&"ping= } if ( $HEALTHCHECK_UUID -ne "" ) { curl https://hc-ping.com/$HEALTHCHECK_UUID } } else { if ( $KUMA_ID -ne "" ){ curl https://$KUMA_URL/api/push/$KUMA_ID?status=down"&"msg=Failed"&"ping= } if ( $HEALTHCHECK_UUID -ne "" ) { curl https://hc-ping.com/$HEALTHCHECK_UUID/fail } }