Backup

You can script a backup without too much trouble. If you’re backing up to something foreign to Windows (Like TruNAS) you can use use the WSL to get access to rsync

Prepare TruNAS

On Windows, Get a List of Running VMs

Get-VM |Where-Object { $_.State -eq ‘Running’ } | Select-Object -ExpandProperty Name

Create those on TruNAS as separate datasets (so you manipulate them more easily down the road)

Copy the list from above to a file named ’list’

while read X;do zfs create pool01/replication/$X;done < list

Adjust Permissions

chmod go+w create pool01/replication/*

Prepare Windows

Install Debian

wsl –install –distribution Debian

Install Tools

sudo apt install rsync openssh-client

Create and Copy a Key

ssh-keygen ssh-copy-id [email protected]

Create a PowerShell script

notepad test.ps1

$vmNames = Get-VM |
    Where-Object { $_.State -eq 'Running' } |
    Select-Object -ExpandProperty Name

foreach ($name in $vmNames) {

	$DestPath = "[email protected]:/mnt/pool01/replication/$name/"
	$SourcePath = "E:\$name\Virtual Hard Disks"

	Write-Host "Creating checkpoint for $name..."
	Checkpoint-VM -Name $name -SnapshotName "TempRsync"
	
	# Note the single quotes to pass the file globs through to linux
	Write-Host "Launching WSL for rsync"
	wsl --cd "$SourcePath" rsync -avz --inplace --progress '*.vh*' "$DestPath"

	Write-Host "Merging checkpoint..."
	Get-VMSnapshot -VMName $name -Name "TempRsync" | Remove-VMSnapshot
}

Last modified April 6, 2026: file backup and sync addition (cbcf556)