Jump to content
  • Solutions to Replicate/Sync Your Citrix Provisioning Services (PVS) Store


    christwiestrnd.png.3893df3d7212cb14f60c8dbe154fe2ed.png by Chris Twiest

    twiest032818-03.png.76b2c9495e6563297ba5e479d534f547.png 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.

    twiest032818-02.png.87f4743e67dbbac78681c485e48c04df.png 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.



    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 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.



    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.



    #### User Parameters

    $StorePath1 = "\\PVSSERVER01\E$"

    $StorePath2 = "\\PVSSERVER02\E$"

    $Date = Get-Date -format yyyy-MM-dd

    $Diskname = "VDIwin10-1703-3DPRO-$date"


    #### Script Parameters

    $file1 = "$StorePath1\$Diskname.vhdx"

    $file2 = "$StorePath2\$Diskname.vhdx"

    $pvp1 = "$StorePath1\$Diskname.pvp"

    $pvp2 = "$StorePath2\$Diskname.pvp"

    $store1 = "$StorePath1"

    $store2 = "$StorePath2"


    #### Check Disk location and copy

    $testfile1 = $file1 | test-path

    if ($testfile1 -eq $False){

    Write-Host "Disk not found on location $file1"

    Write-Host "Copy disk from location $file2"

    Copy-Item -Path $file2 -Destination $store1

    Copy-Item -Path $pvp2 -Destination $store1


    $testfile2 = $file2 | test-path

    if ($testfile2 -eq $False){

    Write-Host "Disk not found on location $file2"

    Write-Host "Copy disk from location $file1"

    Copy-Item -Path $file1 -Destination $store2

    Copy-Item -Path $pvp1 -Destination $store2



    #### Check Disk size and copy

    $length1 = Get-Item -Path $file1 | select length

    $length2 = Get-Item -Path $file2 | select length

    if ($length1 -like $length2){

    write-host "Disk is in sync"

    } else{

    write-host "Disk is not in sync"

    if ($length1.Length -gt $length2.Length){

        write-host "$file1 is larger then $file2"

        write-host "Delete $file2 and $pvp2"

        remove-item -Path $file2 -Force

        remove-item -Path $pvp2 -Force

        write-host "Copy $file1 too $store2"

        Copy-Item -Path $file1 -Destination $store2

        Copy-Item -Path $pvp1 -Destination $store2





    if ($length2.Length -gt $length1.Length){

        write-host "$file2 is larger then $file1"

        write-host "Delete $file1"

     remove-item -Path $file1 -Force

        remove-item -Path $pvp1 -Force

        write-host "Copy $file2 too $store1"

        Copy-Item -Path $file2 -Destination $store1

        Copy-Item -Path $pvp2 -Destination $store1



    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.



    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:

    1. Download FreeFileSync form here. Then install the tool on your primary PVS server.

    2. Open the FreeFileSync application.

    3. 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.


    4. Press F6 Select File time and size.


    5. Press F7 and add *.lok to exclusions if you use server write cache. Make sure to also exclude the folder here.


    6. Press F8 and select <-Two way-> and Permanent and check Ignore Errors 


    7. Click on OK and click on the Save as Batch Job Icon.

    8. Check run minimized, Ignore Errors, and save log and scroll to Exit When finished. Fill in a log location and  Limit the logs.


    9. Click on Save as... and give your batch a name like Sync_PVS-Store.ffs_batch

    10. 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."



    I hope this will help you keep your PVS store sync and find an effortless way to replicate your vDisk. Of course, if possible, I would recommend automating the whole process!

    User Feedback

    Recommended Comments

    Guest Looking Back Over 2018 – A Lot of Great Content for CUGC! – BLOGS


    […] Chris Twiest posted a detailed look at Solutions to Replicate/Sync Your Citrix Provisioning Services (PVS) Store. […]
















    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Create New...