Solutions to replicate/sync your Citrix Provisioning Services (PVS) Store
Everyone who uses Citrix Provisioning Services (PVS) knows that it is important to make your vDisk and PVS servers High Available. There are two ways to do this. You can share high available (centralized) storage between your PVS servers or you can attach local storage to each PVS server to create a local store. In the real world, I have seen the local storage option way more times than the shared storage option. And for good reason: it’s just easier to setup. Just create two VMs with an extra virtual hard-drive to both and you’re done. But to create high availability the vDisks must be available to both servers in their local storage. The challenge here is making sure your PVS Stores on the local storage are the same. So, in this blog I would like to share with you solutions to replicating/syncing your PVS store. I will be referring to some well-known solutions (from other blogs) and some new ones.
If you want to know more about setting up your store, I would advise reading PVS internals part 3 by Martin Zugec on the Citrix Blog here.
This image comes from the PVS internal blog and demonstrates the setup of 3 PVS servers, each with their own Local Store and replications of the vDisk. In this blog, we will be talking about the blue line.
Martin Zugec pointed out that one thing to consider before choosing a solution is that when a copy is done with a buffer, the PVS RAM Cache of both the sending and the receiving pvs server is emptied. And, this will negatively impact performance. With DFS-R, this can be prevented, and partly with automated file copiers, but you must use unbuffered copy (non-default configuration RoboCopy /J). FreeFileSync doesn’t have the option. Martin will write about it in an upcoming PVS Internals Part 4 blog.
Automation
As some of you might know, my motto is Automate Everything! I once had an old wise system administrator say to me: “If you must do a task more than once it is worth scripting/automating it.” On my blog, I have a guide to create a new vDisk automatically from scratch with RES/ Ivanti Automation, which can be found here. With this in mind, I also think that the syncing/replication of the vDisks must be automated. Therefore, at the pros and cons of every solution, I look at automation capabilities.
Replication / Sync Solutions
Manual Copy:
The first, and the simplest, solution is just to copy the files manually. On the first PVS server, you open the file explorer and browse to \\PVSServer2\D$ (if your store is located at the D: drive). Then simply select the vDisk on PVS Server 1 store you want to replicate and press CTRL+C go to the other explorer window and press CRTL+V.
- Pros
- You have full control of what is being replicated.
- You can easily see the replication speed and time to finish.
- It cannot be automated.
- Cons
- Manual copy can easily be forgotten making it a risk to your High Availability.
- Because it must be done manually, it takes time for the System Administrator to do.
RoboCopy:
This is a tool which can copy files from one location to another in a CMDLET form, and is part of the Windows 2008 resource kit. The easiest way to use RoboCopy is to make a copy.bat file on the desktop of the PVS server and add the following code from Carl Stalhood on his website here.
REM RoboCopy from PVS01 to PVS02 REM Deletes files from other server if not present on local server RoboCopy D:\vDisks \\pvs02\d$\vDisks *.vhd *.vhdx *.avhd *.avhdx *.pvp /b /mir /xf *.lok /xd WriteCache /xo
Then, when you want to replicate your store, simply launch the Copy.bat from the desktop and RoboCopy will sync your PVS stores.
- Pros
- RoboCopy is a robust file copier with mirroring and exclusion capabilities.
- You can add logging capability to RoboCopy to see what is being copied and how long it takes.
- It can be used in an Automation process.
- Cons
- It requires a manual or automated starting action.
- RoboCopy is an older file copier with less support than, for example, PowerShell.
DFS-R:
DFS-R is Microsoft’s own replication tool, which comes with Windows server 2003R2 and up. It can replicate and sync to share between servers. To setup DFS-R for your PVS store, you can follow the blog post here on the blog of Bram Wolfs. One thing I want to point out from the blog directly is the command to check the backlog: dfsrdiag backlog /receivingmember:PVS03 /rfname:PVS_Store_01 /rgname:PVS_Store_01 /sendingmember:PVS01 DFS-R can be somewhat of a black box and you might be waiting on your replication and it’s not happening.
- Pros
- It comes standard with Windows Server.
- It has two-way replication capability.
- It syncs constantly.
- Cons
- Because it syncs constantly, you might need to turn the service on or off during an automation process.
- When using automation, it is difficult to know when the stores are finished replicating.
- DFS-R doesn’t really handle the big files from the vDisk’s well, the staging folder needs to be increased.
PowerShell:
With PowerShell, you can of course utilize the Copy-Item cmdlet to copy your disk from one store to another. I create my vDisks automatically, and I ran into a small issue when using the Start-PVSCreateDisk to create my new disk. The issue is that if you want your disk to be load balanced, you must create the disk without the -servername attribute. But this means that you don’t know which store will host the disk once you start imaging your Target C: drive to the vDisk (Preferably with BIS-F off course). So, I created this PowerShell script to run after the imaging to check where the vDisk is and which vDisk is larger. After that, it will replicate the complete disk to the other Store.
Another way to keep your PVS store in sync with PowerShell is using the vDisk Replication script created by Samuel Breslow which can be found here on the Citrix Blogs.
- Pros
- PowerShell gives you the tools to create your own replication script.
- You can add logging to see what’s copying and how long it takes.
- It can easily be used in an Automation process.
- Cons
- It requires a manual or automated starting action.
FreeFileSync:
This is a freeware tool to sync two folders with each other. The tool has a GUI to setup the syncing of your store and after that can be run through command-line. Because there is not much written about setting up FreeFileSync with Citrix PVS, I will include the instructions:
- Download FreeFileSync form here. Then install the tool on your primary PVS server.
- Open the FreeFileSync application.
- Beneath the Drag & Drop, click on browse and select the store on the PVS server on the right side. Browse to the UNC path of the other store.
- Press F6 and Select File time and size..
- Press F7 and add *.lok to exclusions if you use server write cache. Make sure to also exclude the folder here.
- Press F8 and select <-Two way-> and Permanent and check Ignore Errors
- Click on OK and click on the Save as Batch Job Icon.
- Check run minimized, Ignore Errors, and save log and scroll to Exit When finished. Fill in a log location and Limit the logs.
- Click on Save as… and give your batch a name like Sync_PVS-Store.ffs_batch
- To run your sync, run the following command: “C:\Program Files\FreeFileSync\FreeFileSync.exe” “%LOCATIONOFJOBFILE%\Sync_PVS-store.ffs_batch”. While running the sync, you will find a log in the log folder with all details of what’s going on during the sync.
- Pros
- Easily setup.
- Clear log file.
- Can be used in an automation process.
- Freeware.
- Cons
- Requires an installation on a PVS server.
- It requires a manual or automated starting action.
Enable HA PVS
So, here are a few solutions to keep your PVS store in sync! It is of course necessary to enable HA on your vDisks. You do this by right-clicking on the vDisk in the Provisioning Console and selecting Load Balancing, then select “Use the load balancing algorithm.”
Conclusion
Hope this will help you keep your PVS store sync and find a easy way to replicate your vDisk. Off course if possible I would recommend automating the hole process!
I hope this was informative. For questions or comments you can always give a reaction in the comment section or contact me: