Server email backup rapport Question

Topic Author
  • Posts: 127
  • Karma:
  • Gender: Unknown
  • Birthdate: 11 Sep 2019
Server email backup rapport #143
Link til original artikel:
www.sakiyna.com/step-by-step-windows-ser...2-with-email-alerts/

OBS! Der ligger et par færdige scripts i "firma mappen", som fungerer med Office 365 konto (intern besked, ikke relevant for andre end mine kollegaer).

Uddrag:
Step by Step – Windows Server Backup on Windows Server 2012 R2 with Email Alerts
by Abduvali Davronov|Published January 19, 2018
Setting up Windows Server Backup with email alert notifications
For Active Directory Backup and Recovery Microsoft's preferred tool is Windows Server Backup (WSB). WSB got improved a lot in the latest versions of Windows Server. It comes as a built-in feature that can be activated using Server Manager.
Aims of this guide
We will install the WSB using Server Manager, configure basic (Full Server) backup job schedule and set up a scheduled task to send out email notifications every time backup succeeds or fails. For email notifications we will use Powershell script.
Step 1. Install Windows Server Backup
We will install the WSB using Server Manager's Add Roles and Features wizard.
Install WSB
Install WSB
Step 2. Start Windows Server Backup
We start WSB from Server Manager's Tools menu.
Start WSB
Start WSB
Step 3. Schedule first backup job
We run backup scheduling wizard from Actions pane. For backup type select Full server. Choose your required backup frequency and time. For Destination Type choose Backup to a volume and add the local volume dedicated for backups. When WSB prompts you to exclude the backup destination volume from the backup job click OK and complete the Backup Schedule Wizard.
Scheduling first backup job
Scheduling first backup job
Step 4. Prepare email notification Powershell scripts
Here is a sample script for Backup Success Email Task. You can change values in red to your own ones. Call it email-success.ps1 and copy it to C:\Windows\System32 folder.
#Send Backup Success Email
$secpasswd = ConvertTo-SecureString “PASSWORD” -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential (“This email address is being protected from spambots. You need JavaScript enabled to view it.”, $secpasswd)

Send-MailMessage -from "This email address is being protected from spambots. You need JavaScript enabled to view it." `
-To "FIRST@EMAIL.COM","SECOND@EMAIL.COM" `
-Subject "Success - Windows Server backup" `
-SmtpServer "YOUR.SMTP.SERVER" `
-Credential $mycreds `
-UseSsl `
-Port "587" `
-Body "YOUR COMPANY Windows Server Backup is successful"
This is a sample script for Backup Failure Email Task. You can change values in red to your own ones. Call it email-failure.ps1 and copy it to C:\Windows\System32 folder.
#Send Backup Failure Email
$secpasswd = ConvertTo-SecureString “PASSWORD” -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential (“This email address is being protected from spambots. You need JavaScript enabled to view it.”, $secpasswd)

Send-MailMessage -from "This email address is being protected from spambots. You need JavaScript enabled to view it." `
-To "FIRST@EMAIL.COM","SECOND@EMAIL.COM" `
-Subject "Failure - Windows Server backup" `
-SmtpServer "YOUR.SMTP.SERVER" `
-Credential $mycreds `
-UseSsl `
-Port "587" `
-Body "YOUR COMPANY Windows Server backup failed"

Step 5. Launch Task Scheduler
Launch Task Scheduler from Server Manager's Tools menu
Launch Task Scheduler
Launch Task Scheduler
Step 6. Create the first task for 'Backup Success' email alerts
On Create Task wizard's General tab give the task a name (eg Backup Success Email Task). Give it a meaningful description (eg Notifies of scheduled backup successful completion). Under Security options section select Run whether user is logged on or not.
Create Task
Create Task
Step 7. Add a trigger for the task
For Begin the task select On an event. In Settings section leave Basic checked and under Log: choose Microsoft-Windows-Backup/Operational. For Event ID enter number 4. In Advanced settings section tick Stop task if it runs longer than: and choose 1 hour. Also make sure option Enabled is ticked.
Add a trigger for the task
Add a trigger for the task
Step 8. Add an action for the task
In Actions tab click on New... In Edit Action window for Action select Start a program. In Program/script box type in Powershell.exe and in Add arguments box type in -EP Bypass c:\Windows\System32\email-success.ps1. Click OK to confirm the action.
Add an action for the task
Add an action for the task
Step 9. Finalise the task
In Settings tab set Stop the task if it runs longer than: to 1 hour. Click OK and on credentials prompt enter the credentials required for running the task.
Finalise the task
Finalise the task
Step 10. Create the task for 'Backup Failure' email alerts
For Backup Failure Email Task follow the steps 6 to 9, except with the following differences. In General tab give it a different name and description. On Triggers tab create individual triggers for Events 5, 8, 9, 17, 18,19, 20, 21, 22, 49, 50, 561. For Actions tab specify the email-falure.ps1 script instead.
Create Email failure task
Create Email failure task
7 months 3 weeks ago Last edit: 7 months 3 weeks ago by clintenadmin.

Please Log in to join the conversation.

Time to create page: 0.368 seconds