Open TripleNico opened 1 year ago
Thank you for this, very interesting! I'll work on getting these enhancements implemented in future.
I'm adding all the suggestions here except for the Wake On Lan option for the time being. WOL feels a little out of scope but I'm willing to add it if there's a demand.
First of all let me say i really like you're way of scripting and love to see your enthusiasm in your work.
Last year i've made my own version of you script then because i needed to be more lightweight and there were a few things not available then like the
-LowDisk
switch. But today i've check what you've been working at and i'm impressed, it almost fits my need and i know it's a lot to ask (since i can do it myself) but could you consider to add these features?[x] Switch called
-SendStatusUpdate
: this features send after every VM a email with the status of that VM export. For example, in my case i have a few VM's that are TB's and the script runs at night. When it's morning i can see due to the emails where the backup script is in the process. I simply put aSendEmail
at the end of theForEach VM
(Check second code block below)[x] Switch calles
-OptimizeVHD
: this features uses theOptimize-VHD
function before copying it to the backup destination. Example of the code i use inside theForEach VM
:[x] Print the duration of how long it took per VM to back. In my script i simply compare time from the beginning of the
ForEach VM
and in one of the last lines print the duration. This gives me a pretty good idea how long it takes per VM. For example:... do stuff ...
$elapsedTime = $(get-date) - $StartTime $totalTime = "{0:HH:mm:ss}" -f ([datetime]$elapsedTime.Ticks) SendMail "VM $Vm done" "Processed VM: $Vm in $totalTime" Write-Log -Type Info "-------------------------- Done processing VM: $Vm in $totalTime --------------------------------" Write-Log -Type Info ""
[ ] Extra funtions start Start and Stop a backupserver. This is something i have in my script because when the backuopserver isn't needed it is shutdown. (For security and power reasons). Snippit of the code:
... later on ...
Let's start the BackupServer if it's not running
If (Test-Connection -ComputerName "IP/Hostname" -Count 2 -Delay 5 -Quiet ) {
Backup server responded meaning it's already online.
} else { Write-Log -Type Info -Evt "Sending magic packet to BackupServer [$BackupServerMacAddress]" Invoke-WakeOnLan -MacAddress "$BackupServerMacAddress" -Verbose
Now wait until backupserver is online
}
... When done, shutdown ...
Now shutdown the backup server
Try { Write-Log -Type Info -Evt "Waiting for BackupServer to shutdown..." Stop-Computer -ComputerName "IP/Hostname" -Credential $credObject -Force
Wait until backupserver is down
} catch { Write-Log -Type Err -Evt "Error backup shutdown: $($_.Exception.Message)" }