board logo
DogMan
  • DogMan
  • 100% (Exalted)
  • Newbie Topic Starter
5 months ago
Is there a way to make replication in hyper-v work differently - like only taking replications at low usage times rather than every 15 minutes
Recycling Computers  is my hobby so if you have any old PCs or Macs..
Sponsor

Want to thank us? Use: Patreon or PayPal or Bitcoins: bc1q4whppe29dw77rm4kv4pln0gqae4yjnxly0dny0hky6yhnafukzjsyrsqhk

All opinions expressed within these pages are sent in by members of the public or by our staff in their spare time, and as such do not represent any opinion held by sircles.net Ltd or their partners.

sirclesadmin
5 months ago
Short answer: No, not natively. The built-in Hyper-V Replica settings are hard-coded to intervals of 30 seconds, 5 minutes, or 15 minutes.
However, you can "hack" this behavior using PowerShell and Task Scheduler to force replication to occur only during specific windows.
The Workaround: Pause & Resume Scripts
You can effectively create a "low usage only" schedule by telling Hyper-V to pause replication during the day and resume it at night.
How to do it:

Create a "Stop" Script: Create a PowerShell script that runs in the morning (e.g., 8:00 AM) to pause replication.

Suspend-VMReplication -VMName "YourVMName"


Create a "Start" Script: Create a second script that runs at night (e.g., 2:00 AM) to resume replication.

Resume-VMReplication -VMName "YourVMName" -Resynchronize


Schedule Them: Use Windows Task Scheduler on the primary Hyper-V host to trigger these scripts at your desired times.

Critical Warnings
If you choose this method, you must be aware of significant risks that standard 15-minute replication avoids:

Massive Log Files (HRL): During the day, Hyper-V tracks every single change in a .HRL log file. If your server is busy, this file can grow to be hundreds of gigabytes by the time night comes. If you run out of disk space, your VM will pause or crash.
Long Sync Times: When replication resumes at 2 AM, it has to push an entire day's worth of data at once. If the "low usage" window isn't long enough to transfer that data, replication will fail or bleed into the next day.
Data Loss Risk (RPO): If your primary server crashes at 5:00 PM, you will lose all data changed since the previous night's replication. You lose the primary benefit of replication (near real-time recovery).

Better Alternatives
If you only want to move data once a day, you are likely looking for Backup rather than Replication.

Standard Backups: Use Veeam, Altaro, or Windows Server Backup to take a nightly incremental backup. This is designed for daily intervals and handles the "snapshot" cleanup much better than a paused replica.
Third-Party Replication: Tools like Veeam Backup & Replication allow you to schedule replication jobs explicitly (e.g., "Run daily at 3 AM") without the risks of manual pausing.




This video is relevant because it visually demonstrates the "Pause" and "Resume" replication functions in the Hyper-V manager, which are the exact controls you would need to automate for a custom schedule.

DogMan
  • DogMan
  • 100% (Exalted)
  • Newbie Topic Starter
5 months ago
Will the replication reliably pickup again after this break in communication? Is there a powershell way we could start and stop it reliably with a sort of 'stop whinging and get on with it' pickup command each weekday evening?
Recycling Computers  is my hobby so if you have any old PCs or Macs..
sirclesadmin
5 months ago

Yes, you can absolutely script a "stop whinging and catch up" command using PowerShell. This allows you to force the replication to resume even if Hyper-V is complaining that the logs are too big or the state is "Critical."


Here is the strategy and the specific scripts you need.


The "Stop Whinging" Command (-Resynchronize)


The secret weapon you are looking for is the -Resynchronize switch.


Normally, if you pause replication for too long, Hyper-V puts the VM into a "Resynchronization Required" state and refuses to just "resume" normally because it's afraid it lost track of changes.



  • Normal Command: Resume-VMReplication (Fails if the gap was too long/complex).

  • "Just Fix It" Command: Resume-VMReplication -Resynchronize (Forces Hyper-V to compare the disks and get back in sync, ignoring the errors).


The Solution: Two Scheduled Scripts


You can set these up in Windows Task Scheduler on your primary server.


1. The Morning "Pause" Script (e.g., 8:00 AM)


This simply pauses the replication so it doesn't eat up bandwidth during the day.


# Save as PauseReplication.ps1 
Suspend-VMReplication -VMName "YourVMName"

2. The Evening "Pickup" Script (e.g., 6:00 PM)


This script checks the status. If it's just paused, it resumes. If Hyper-V is "whinging" (Critical/Resync Required), it forces the resync.


# Save as ResumeReplication.ps1 
$VMName = "YourVMName"
$RepInfo = Get-VMReplication -VMName $VMName
# Option 1: It's just paused (Good scenario)
if ($RepInfo.State -eq 'Paused') {
Write-Host "Resuming normal replication..."
Resume-VMReplication -VMName $VMName
} # Option 2: It's whinging (Critical / Resync Required scenario)
elseif ($RepInfo.Health -eq 'Critical' -or $RepInfo.State -eq 'ResynchronizationRequired') {
Write-Host "State is Critical. Forcing Resynchronization (The 'Stop Whinging' method)..."
Resume-VMReplication -VMName $VMName -Resynchronize
} # Option 3: It's already fine
else {
Write-Host "Replication appears to be running or in an unknown state."
}

Will it be reliable? (The Risk)


It will generally be mechanically reliable (the script will run and force the action), but there is a performance "catch" you must know:



  1. The "Resync" Penalty: If the script triggers the -Resynchronize command, Hyper-V stops simply sending the log file and instead has to read the entire hard drive of the VM to compare it with the replica. This is disk-intensive.

  2. The Time Crunch: If you changed 50GB of data during the day, that evening resync might take 4-5 hours to transfer. If it's still running when your morning "Pause" script fires at 8:00 AM, you might end up in a loop where it never fully catches up.


Recommendation: Run the evening script manually the first few times to see how long the "catch up" actually takes on your specific network. If it finishes in 2 hours, you are safe to automate it.