Backup Virtual-Hard-Disk: Difference between revisions
No edit summary |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Easy and cheap way to backup your running Hyper-V disks. The script is using the [https://de.wikipedia.org/wiki/Volume_Shadow_Copy_Service VSS] technology to allow you to backup your disk even if the VM is in use.<br> | |||
The script | The script is using an individual xml configuration to allow a flexible way of doing backups<br> | ||
The Chilcat ActiveX component is needed for reading the configuration, please get it [https://www.chilkatsoft.com/downloads_ActiveX.asp here]<br> | |||
* The script has been tested on Windows 10 and Server 2016.<br><br> | |||
Syntax: | |||
> cscript hvbackup.vbs | |||
Note that the default configuration (hvbackup.xml) is getting loaded if no parameter is given | |||
<br><br> | |||
Alternative Syntax | |||
> cscript hvbackup.vbs <optional configuration.xml> | |||
==Setup hvbackup.xml== | |||
*Edit '''hvbackup.xml''' | |||
{| style="border: 1px solid #FFF0C0;" | |||
|+ '''psad2ipt.xml''' | |||
|----- | |||
! align="left" valign="top" bgcolor="#ffff99" style="padding:5px;"| XML Child Element | |||
! align="left" valign="top" bgcolor="#ffff99" style="padding:5px;"| XML Attribute | |||
! align="left" valign="top" bgcolor="#ffff99" style="padding:5px;"| Value | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
SETUP | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
VSSPath | |||
| The VSSPath is a symbolic link to be used and created by the script to copy the data through VSS | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
VSSCheck | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
Optional value (0 or 1) to specify if the VSS should be created on startup, it is recommended to do so.<br> | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
VSSAutomaticCreate | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
Set to create the create the VSSS, (0 or 1). It is recommended to do so.<br> | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
WriteLogfile | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
Switch on log file writing which is recommended. (0 or 1) | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
LogPath | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
Specify the directory where the logs should get written to | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
SourcePath | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
Specify the root directory of your VM, please note that the script recursive walks down all paths and tries to find VHDX files. | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
TargetPath | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
Specify the target directory where you want to backup your disks. | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
MinFreeDiskSpaceGB | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
Check the amount of free disk space on the target befoe we refuse the backup operation. | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
DataRetention | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
Amount of disks which we keep on the target | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
RemoveVSSOnExit | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
Specify (0 or 1) to remove the VSS once the backup operation has been completed, recommend to do so. | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
Filter (Array) | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
String | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
Any alphanumeric string to search for disk names | |||
|----- | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px: 1px solid #F3F781; "| | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
Type | |||
| align="left" valign="top" bgcolor="#ffffff" style="padding:5px; border: 1px solid #F3F781;"| | |||
The type of filter, this can be '''include''' or '''exclude''' | |||
|} | |||
==Example== | |||
<?xml version="1.0"?> | |||
<CONFIG> | |||
<Setup> | |||
<VSSPath>c:\$vss$</VSSPath> | |||
<VSSCheck>1</VSSCheck> | |||
<VSSAutomaticCreate>1</VSSAutomaticCreate> | |||
<WriteLogfile>1</WriteLogfile> | |||
<LogPath>c:\logs</LogPath> | |||
<SourcePath>c:\virtual-machines</SourcePath> | |||
<TargetPath>\\myTargetServer\Backup\</TargetPath> | |||
<MinFreeDiskSpaceGB>50</MinFreeDiskSpaceGB> | |||
<DataRetention>3</DataRetention> | |||
<RemoveVSSOnExit>1</RemoveVSSOnExit> | |||
</Setup> | |||
<Filters> | |||
<Filter> | |||
<String>vm-anyname</String> | |||
<Type>include</Type> | |||
</Filter> | |||
<Filter> | |||
<String>another disk name</String> | |||
<Type>include</Type> | |||
</Filter> | |||
<Filter> | |||
<String>one more disk name</String> | |||
<Type>include</Type> | |||
</Filter> | |||
<Filter> | |||
<String>exclude this disk</String> | |||
<Type>exclude</Type> | |||
</Filter> | |||
<Filter> | |||
<String>exclude another disk name</String> | |||
<Type>exclude</Type> | |||
</Filter> | |||
</Filters> | |||
</CONFIG> | |||
=Download= | |||
<br> | |||
{| style="width: 70%;" | |||
|style="width:10%; vertical-align: top;"| | |||
'''Download the script'''<br> | |||
[[File:Download.png|60px|link=https://coolscript.org/download/scripts/hvbackup.zip|Download]] | |||
<br> | |||
|style="width:90%; vertical-align: top;"| | |||
<br> | |||
|} |
Latest revision as of 14:10, 5 October 2023
Easy and cheap way to backup your running Hyper-V disks. The script is using the VSS technology to allow you to backup your disk even if the VM is in use.
The script is using an individual xml configuration to allow a flexible way of doing backups
The Chilcat ActiveX component is needed for reading the configuration, please get it here
- The script has been tested on Windows 10 and Server 2016.
Syntax:
> cscript hvbackup.vbs
Note that the default configuration (hvbackup.xml) is getting loaded if no parameter is given
Alternative Syntax
> cscript hvbackup.vbs <optional configuration.xml>
Setup hvbackup.xml
- Edit hvbackup.xml
XML Child Element | XML Attribute | Value |
---|---|---|
SETUP |
VSSPath |
The VSSPath is a symbolic link to be used and created by the script to copy the data through VSS |
VSSCheck |
Optional value (0 or 1) to specify if the VSS should be created on startup, it is recommended to do so. | |
VSSAutomaticCreate |
Set to create the create the VSSS, (0 or 1). It is recommended to do so. | |
WriteLogfile |
Switch on log file writing which is recommended. (0 or 1) | |
LogPath |
Specify the directory where the logs should get written to | |
SourcePath |
Specify the root directory of your VM, please note that the script recursive walks down all paths and tries to find VHDX files. | |
TargetPath |
Specify the target directory where you want to backup your disks. | |
MinFreeDiskSpaceGB |
Check the amount of free disk space on the target befoe we refuse the backup operation. | |
DataRetention |
Amount of disks which we keep on the target | |
RemoveVSSOnExit |
Specify (0 or 1) to remove the VSS once the backup operation has been completed, recommend to do so. | |
Filter (Array) |
String |
Any alphanumeric string to search for disk names |
Type |
The type of filter, this can be include or exclude |
Example
<?xml version="1.0"?> <CONFIG> <Setup> <VSSPath>c:\$vss$</VSSPath> <VSSCheck>1</VSSCheck> <VSSAutomaticCreate>1</VSSAutomaticCreate> <WriteLogfile>1</WriteLogfile> <LogPath>c:\logs</LogPath> <SourcePath>c:\virtual-machines</SourcePath> <TargetPath>\\myTargetServer\Backup\</TargetPath> <MinFreeDiskSpaceGB>50</MinFreeDiskSpaceGB> <DataRetention>3</DataRetention> <RemoveVSSOnExit>1</RemoveVSSOnExit> </Setup> <Filters> <Filter> <String>vm-anyname</String> <Type>include</Type> </Filter> <Filter> <String>another disk name</String> <Type>include</Type> </Filter> <Filter> <String>one more disk name</String> <Type>include</Type> </Filter> <Filter> <String>exclude this disk</String> <Type>exclude</Type> </Filter> <Filter> <String>exclude another disk name</String> <Type>exclude</Type> </Filter> </Filters> </CONFIG>
Download
|