Ad Widget

Collapse

4 Windows Backup Monitoring Scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frater
    Senior Member
    • Oct 2010
    • 340

    #1

    4 Windows Backup Monitoring Scripts

    With these items I can monitor if my backupvolumes are attached, if all the big volumes are set to be backed up.
    It happened a few times that a new drive was installed on a server because the original was too small to contain all data. Later we noticed that this drive wasn't added to the back-up...

    Well, here it is.

    I can't get used to this Windows scripting.

    Code:
    UserParameter=system.notbackuped,mode con cols=240 && PowerShell -nologo -File "C:\Program Files (x86)\Zabbix Agent\NotBackuped.ps1"
    UserParameter=system.backupvolumes,mode con cols=240 && PowerShell -nologo -File "C:\Program Files (x86)\Zabbix Agent\BackupVolumes.ps1"
    UserParameter=system.backupcount,mode con cols=240 && PowerShell -nologo -File "C:\Program Files (x86)\Zabbix Agent\BackupVolumes.ps1" | findstr /I "[a-z]" | find /c /v ""
    UserParameter=system.volumes,mode con cols=240 && PowerShell -nologo -File "C:\Program Files (x86)\Zabbix Agent\Volumes.ps1"
    UserParameter=system.backuped,mode con cols=240 && PowerShell -nologo -File "C:\Program Files (x86)\Zabbix Agent\Backuped.ps1"
    Backupped.ps1
    Code:
    add-pssnapin windows.serverbackup 
    Get-WBpolicy | Format-Table VolumesToBackup -AutoSize -HideTableHeaders
    BackupVolumes.ps1
    Code:
    add-pssnapin windows.serverbackup 
    
    # Get Harddisks
    $drives = Get-WMIObject -query "SELECT * from Win32_Volume where Capacity > 49999999999 and DriveType = 3 " | ForEach-Object {$_.Label}
    # Get BackupTargets
    Get-WBpolicy | Format-Table BackupTargets -HideTableHeaders -AutoSize >BACKUPDRIVES
    echo $null > DRIVESFOUND
    # Parse file BACKUPDRIVES with the volumenames of the currently attached harddisks
    foreach ($line in $drives)
    {
      if ( $line ) {
        $isbackupdrive = Select-String -SimpleMatch -Pattern "$line" BACKUPDRIVES
        if ($isbackupdrive) {
          Write-Output $line | Out-File -FilePath DRIVESFOUND -Append
    	}
      }
    }
    
    If ((Get-Content "DRIVESFOUND") -eq $Null) {
      Write-Host "."
    }
    else {
      Get-Content "DRIVESFOUND"
    }
    NotBackuped.ps1
    Code:
    add-pssnapin windows.serverbackup 
    
    # Get Harddisks with a driveletter
    $harddisks = Get-WMIObject -query "SELECT * from win32_logicaldisk where Size > 4999999999 and DriveType = 3"  | Where-Object {$_.VolumeName -NotMatch 'Back'} | ForEach-Object {$_.DeviceID}
    
    Get-WBpolicy | Format-Table VolumesToBackup -HideTableHeaders -AutoSize >BACKUPED
    
    $notbackuped = ""
    # Parse file with driveletters and check if they exist in the current backup-set
    foreach ($line in $harddisks)
    {
      $isbackuped = select-string -pattern $line BACKUPED
      if (!$isbackuped) {
        $notbackuped = "$notbackuped $line"
      }
    }
    
    # Write a dot for a system that has all harddisks backuped or the missing harddisks
    if ($notbackuped) {
      Write-Host $notbackuped
    }
    else
    {
      Write-Host "."
    }
    Volumes.ps1
    Code:
    Get-WMIObject -query "SELECT * from win32_logicaldisk where DriveType = 3" | Format-Table DeviceID, VolumeName -AutoSize -HideTableHeaders
    Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP
Working...