Digressive / HyperV-Backup-Utility

Flexible Hyper-V Backup Utility
https://gal.vin/posts/vm-backup-for-hyper-v/
MIT License
120 stars 38 forks source link

Error in creating a backup (version 22.03.26) #21

Closed PitNorton closed 2 years ago

PitNorton commented 2 years ago

Hi, I use version 22.03.26 with the following parameters:

C:\Tasks\hyper-v-backup.ps1 -BackupTo d:\backup\hyper-v -List C:\Tasks\vm-name.lst -Wd D:\NVE\Temp -Keep 10 -Compress -Sz -SzOptions '-t7z' -L C:\Tasks\Logs -ShortDate

The archive of the virtual machine was created, but the entire contents of the C:\Tasks with subdirectory are moved to -BackupTo This is wrong.

I think the mistake is here

703: $BackupFile = Get-ChildItem -Path ("$WorkDir\$VmFixed-$(Get-DateShort).*") -File 704: $BackupFileN = $BackupFile.name

Digressive commented 2 years ago

I can't reproduce this error in the new version: 22.06.11, so hopefully fixed. Thanks

PitNorton commented 2 years ago

Hi, Mike.

You wrote 15.06.2022, 2:53:28:

[..]

I can't reproduce this error in the new version: 22.06.11, so hopefully fixed. Thanks

In the new version (22.06.11) this error has been resolved. Thanks. But a new one has appeared. :(

I use Windows Server 2012R2 with Hyper-V role. When I try to start a new version (22.06.11) I get the following:

2022-06-16 09:03:40 [ERROR] Hyper-V is not installed on this local machine.

Looking through your code I found that you check the Hyper-V role with the following string:   903:      Get-Service vmcompute -ErrorAction Stop     However, there is no such service in Windows Server 2012R2   PS C:> Get-Service vm*   Status  Name              DisplayName ------  ----              ----------- Stopped  vmicguestinterface Hyper-V Guest Service Interface Stopped  vmicheartbeat      Hyper-V Heartbeat Service Stopped  vmickvpexchange    Hyper-V Data Exchange Service Stopped  vmicrdv            Hyper-V Remote Desktop Virtualizati... Stopped  vmicshutdown      Hyper-V Guest Shutdown Service Stopped  vmictimesync      Hyper-V Time Synchronization Service Stopped  vmicvss            Hyper-V Volume Shadow Copy Requestor Running  vmms              Hyper-V Virtual Machine Management   I solved the problem this way:   903:      Get-Service vmms -ErrorAction Stop     The service vmms is also available in later versions of Windows Server.   Would that be correct?    Thank you for reading to this point :)  

Digressive commented 2 years ago

That's correct! I'll do an small update with this code added in for Server 2012 R2

Digressive commented 2 years ago

I have now fixed this in version 22.06.17

PitNorton commented 2 years ago

Excuse me, but I will continue our conversation after all... :) I tested the new version (22.06.18) and got the following again:

[ERROR] Hyper-V is not installed on this local machine.

I looked at your code, which gives this error:

876 else { 877 ## Test for Hyper-V feature installed on local machine. 878 try { 879 If ($OSV -eq "6.3.9600")

But at this point the $OSV variable has not yet been defined. :( You define it below.

933 ## getting Windows Version info 934 $OSVMaj = [environment]::OSVersion.Version | Select-Object -expand major 935 $OSVMin = [environment]::OSVersion.Version | Select-Object -expand minor 936 $OSVBui = [environment]::OSVersion.Version | Select-Object -expand build 937 $OSV = "$OSVMaj" + "." + "$OSVMin" + "." + "$OSVBui"

Fix it, please.

P.S.: By the way, $OSV is easier to get with the following code:

$OSV = (Get-WmiObject -class Win32_OperatingSystem -computerName "localhost").Version

Digressive commented 2 years ago

I have now fixed this in version 22.06.22

PitNorton commented 2 years ago

Everything is working fine now. In my case.