„veeam_notify_apprise.ps1“ hinzufügen
This commit is contained in:
48
veeam_notify_apprise.ps1
Normal file
48
veeam_notify_apprise.ps1
Normal file
@@ -0,0 +1,48 @@
|
||||
# Die Variablen müssen korrekt gefüllt werden.
|
||||
#jobname = Name des VEEAM Jobs
|
||||
# vmbackup = true oder false
|
||||
# Wenn es sich um einen Job von VMs handelt muss true gewählt werden.
|
||||
#
|
||||
|
||||
### Vars
|
||||
$USER="MatrixUser"
|
||||
$PASS="MatrixPassword"
|
||||
$SERVER="matrixserver.tld"
|
||||
$ROOMID="MatrixRoomID"
|
||||
$url="http://1.2.3.4:1234/notify/"
|
||||
$veeamserver="localhost"
|
||||
$veeampcname="PCName"
|
||||
$veeamuser="UserName"
|
||||
$veeampw="Password"
|
||||
$jobname="JobName"
|
||||
$vmbackup="true"
|
||||
|
||||
Disconnect-VBRServer | out-null
|
||||
connect-vbrserver -server $veeamserver -user $veeampcname\$veeamuser -password $veeampw
|
||||
if ($vmbackup -eq "true") {
|
||||
$job = Get-VBRJob -Name $jobname
|
||||
$jobresult = Get-VBRBackupSession | Where {$_.jobId -eq $job.Id.Guid} | Sort EndTimeUTC -Descending | Select -First 1
|
||||
}
|
||||
if ($vmbackup -eq "false") {
|
||||
$job = Get-VBRComputerBackupJob -Name $jobname
|
||||
$session = Get-VBRComputerBackupJobSession -Name "Plex" | Sort-Object -Descending -Property CreationTime
|
||||
$jobresult = $session[0]
|
||||
}
|
||||
if ($jobresult | Out-String -Stream | Select-String Success) {
|
||||
$RESULT="Backupjob $jobname wurde erfolgreich abgeschlossen."
|
||||
}
|
||||
elseif ($jobresult | Out-String -Stream | Select-String Warning) {
|
||||
$RESULT="Backupjob $jobname wurde mit Warning abgeschlossen."
|
||||
}
|
||||
elseif ($jobresult | Out-String -Stream | Select-String Failed) {
|
||||
$RESULT="Backupjob $jobname wurde mit Failed abgeschlossen, bitte prüfen."
|
||||
}
|
||||
Disconnect-VBRServer | out-null
|
||||
$JSON = @"
|
||||
{
|
||||
"urls":"matrixs://$USER`:$PASS@$SERVER/$ROOMID",
|
||||
"body":"$RESULT",
|
||||
"title":"VEEAM Backup"
|
||||
}
|
||||
"@
|
||||
Invoke-RestMethod -Uri $url -Method Post -Body $JSON -ContentType "application/json"
|
||||
Reference in New Issue
Block a user