Scheduling replication Hyper-v

HI All,

I have two hyperv servers with the following VMs:

SERVER: Hyperv1
VM: Alice
VM: FreePBX2

SERVER: Hyperv3
VM: TeaCup

I have replication enabled for the Hyperv1 server VMs (Alice and FreePBX2) to replicate to Hyperv3 and for TeaCup to replicate to Hyperv1.

However they are in separate offices connected by a 2mb pipe.  If replication happens all the time, which is the default setting, then there is too much bandwidth used and everything else between the offices is too slow.  

I don;t need a sync every 5 minutes and would like to schedule the replication to happen between 8pm and 7am every night and 24 hours a day on Sundays.

I looked around and found the following link to do this in powershell, but i have never used powershell and so I am really concerned about messing something up.  Is there a better way to do this?  Or otherwise a step by step on powershell?  Maybe a scheduled task that can be created?

Appreciate your help.
colin911Asked:
Who is Participating?
 
MaheshConnect With a Mentor ArchitectCommented:
In the 1st article PowerShell commands are very straight forward and self explanatory

It works with VMName, so you can create test VM, build its replica and start playing around it to get comfort
OR
Test below
Start by creating two batch files on your Hyper-v RECEIVING host.
c:\SuspendReplication.cmd  which contains the command:  powershell suspend-vmreplication *
 c:\ResumeReplication.cmd which contains the command:  powershell resume-vmreplication *

Now, you can create sc tasks through GUI or in the dos window, enter the following commands to schedule the tasks:

schtasks /create /tn “SuspendReplication” /tr c:\SuspendReplication.cmd /sc daily /st 08:00
schtasks /create /tn “ResumeReplication” /tr c:\ResumeReplication.cmd /sc daily /st 17:00

The first suspends replication at 8am and the second resumes at 5pm.
Choose whatever times you prefer to suit your needs.

Additional links
http://technet.microsoft.com/en-us/library/hh848510.aspx
http://blogs.technet.com/b/virtualization/archive/2013/05/10/resynchronization-of-virtual-machines-in-hyper-v-replica.aspx

Hope that helps

Mahesh
0
 
MaheshArchitectCommented:
Hyper-V Replica sends the log files or write changes for a virtual machine (VM) to the replica Hyper-V server for merging to the target virtual hard disk (VHD) every five minutes, and this interval can't be changed. If you want to have more granular control of the bandwidth used by Hyper-V Replica, you have two options.
•Change the port used for the Hyper-V Replica from the default 80 or 443 (which can be done in the GUI or via Windows PowerShell), then use Quality of Service (QoS) to limit bandwidth at different times of the day for that port. This effectively throttles the transmission of the write logs. If insufficient bandwidth was allocated, then the logs would build up until the QoS policy allocated more bandwidth, such as at night, when the logs could be transmitted and catch up.
Check below link for PowerShell command
http://blogs.technet.com/b/tommypatterson/archive/2012/10/10/replication-with-hyper-v-replica-part-ii-restricted-bandwidth-replication-step-by-step.aspx
Also in Replica properties you can vary VSS copy replication interval.

OR

•Use a script to pause replication at certain times, then resume when desired.

Both options need care, because if too much change occurs, the transaction log queue could be very large, taking a long time to send. If if the log size is more than 50 percent of the total VHD sizes, then a full resync operation will be performed. This takes additional IO and time as a block-by-block comparison is performed.

My suggestion is, its not good idea to replicate hyper-v replica over 2 Mbps link
Hyper-V replica if I understand correctly, it should be used in DR scenarios where bandwidth is never a constraint.
You should setup one more Hyper-V server at each location and setup replica locally
OR you can just implement complete VM Backup solution hopefully.

Mahesh
0
 
colin911Author Commented:
thank you Mahesh.  I'd be interested in the script option.  The replication size will not be big because the replication will not occur on the storage HD's.  Those are backed up separately.  so the only change will be in the OS config, and there are very rarely any changes on these.  But since they hold AD, I want to have a spare copy i can turn on.  Not even really a problem if it is dated a few days normally...

however i have no idea how to perform the script option.  I'm more familiar with GUI interfaces rather than scripting...

Would it be a script that I would use for a scheduled task?
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
MaheshArchitectCommented:
you can enable a scheduled job that suspends and resumes a VM replication. The following Cmdlets can be used:

Suspend-VMReplication
Resume-VMReplication

Just check below blog posts for actual commands, it might help
http://vniklas.djungeln.se/2012/11/30/schedule-hyper-v-vm-replication-for-non-office-hours-with-powershell/
http://vniklas.djungeln.se/2012/06/17/using-powershell-v3-scheduling-for-off-hours-hyper-v-vm-maintenanceconfiguring/

Mahesh
0
 
colin911Author Commented:
Yes, this was the link i already saw (sorry did not paste in into my original post).  I don;t have any familiarity with Powershell so was hoping to not have to go this way.  I started entering some of these values but quickly encountered errors and was a bit concerned, which is why I was looking for a way to do it without having to use powershell.

Granted I can use copy and paste and if there is no other way then I will try again i guess, but I really won't know if I have made a mistake or not and if so don't know how to use powershell to fix the mistake.

Is there a batch file I can create and have the scheduled task run that batch at a certain time to enable or stop the replication?  might not be the best method but I would be more comfortable with that...
0
 
colin911Author Commented:
Thank you!  That helps a lot.
0
 
steven freitasCommented:
@Mahesh

Hi I'm pretty new to coding and PowerShell and CMD commands and all that stuff. Could you please clarify what you mean in this line:

"sc tasks through GUI or in the dos window"

SC??
What GUI?
DOS??

Many thanks :)
0
All Courses

From novice to tech pro — start learning today.