Product Documentation

Prepare StorageZones Controller for file recovery

Mar 09, 2016

How you prepare for file recovery depends on where your data is stored:

  • A supported third-party storage system — If you use a third-party storage system with StorageZones Controller, your third-party storage is redundant and a local backup is not required. However, be aware that a ShareFile user who deletes a file has the ability to recover the file from the Recycle Bin for a brief period. A file cannot be recovered from the ShareFile Recycle Bin after 45 days. After the recovery period, the file is removed from the zone and therefore from the redundant third-party storage. If that recovery time is not adequate, consider one of these solutions:
    • Increase the amount of time that a file remains in the ShareFile recycle bin. To do that, change the value of the Period setting in C:\inetpub\wwwroot\Citrix\StorageCenter\SCFileCleanSvc\FileDeleteService.exe.config. For more information, refer to Customize storage cache operations. Keep in mind that increasing the retention time also increases the amount of third-party storage needed.
    • Create a local back up your StorageZone files every seven days and determine the appropriate retention policy for the backups.
  • On-premises storage — If you use a locally-maintained share for private data storage, you are responsible for backing up your on-premises StorageZones Controller local file storage and registry entries. ShareFile archives the corresponding file metadata that resides in the ShareFile cloud for 3 years.
    Important: To protect against data loss, it is critical that you take a snapshot of your StorageZones Controller server, back up its configuration, and back up your local file storage.

After you prepare your StorageZones Controller for file recovery as described in this topic, you can use the ShareFile Administrator console to:

  • Browse your StorageZones for ShareFile Data records for a particular date and time and then tag any files and folders that you want to restore. ShareFile adds the tagged items to a recovery queue. You then run a recovery script to restore the files from your backup to the persistent storage location.

    For more information, refer to Recover files and folders from your ShareFile Data backup.

  • Reconcile the metadata stored on the ShareFile cloud with your on-premises storage when you cannot recover data from your on-premises storage. The ShareFile reconcile feature permanently removes from the ShareFile cloud the metadata for files that are no longer in a StorageZone on a specified date and time.

    For more information, refer to Reconcile the ShareFile cloud with a StorageZone


  • Windows Server 2012 R2 or Windows Server 2008 R2
  • Windows PowerShell (32-bit and 64-bit versions) must support .NET 4 runtime assemblies

    For more information, refer to "PowerShell scripts and commands" in StorageZones Controller system requirements.

  • PsExec.exe

    PsExec enables you to launch PowerShell using the network service account. You can also use PsExec to schedule recovery tasks.

    Download PsExec.exe from and follow the installation instructions on that page.

In this section

Summary of files used for disaster recovery

The following files, located in C:\inetpub\wwwroot\Citrix\StorageCenter\Tools\Disaster Recovery, are used for disaster recovery.

File name Description
DoRecovery.ps1 PowerShell script executed by Windows Task Scheduler to handle the recovery process. This file stores the file backup and storage locations.
Recovery.psm1 PowerShell module that handles the recovery queue operations.
recovery.log Log file that stores the output of a recovery process.
recoveryerror.log Log file that stores the errors in the recovery process.
LitJson.dll A .Net library to handle conversions from and to JSON (JavaScript Object Notation) strings.

To set up the backup folder

On the backup server, create the folder where you will back up the persistentstorage folder.

The StorageZones for ShareFile Data file backup should follow the same layout as the StorageZones Controller persistent storage.

If your backup location does not follow the same layout as the StorageZones Controller persistent storage, you must perform an additional step during the recovery process to copy files from the backup location to the location that you specify in the Recovery PowerShell script.

Storage layout Backup layout
Important: The ShareFile recovery feature does not automatically back up your persistent storage location. You are responsible for choosing a backup utility and running it every 1 to 7 days.

To create a disaster recovery queue

This one-time setup is required. The following command examples use the default StorageZones Controller installation folder.

  1. On the StorageZones Controller, run PowerShell as an administrator.

    For help, refer to Starting Windows PowerShell on Windows Server.

  2. The PowerShell script used in this procedure is unsigned, so you might need to change your PowerShell execution policy.
    1. Determine if your PowerShell execution policy allows you to run local, unsigned scripts: PS C:\>Get-ExecutionPolicy

      For example, a policy of RemoteSigned, Unrestricted, or Bypass allows you to run unsigned scripts.

    2. To change your PowerShell execution policy: PS C:\>Set-ExecutionPolicy RemoteSigned
  3. To verify that PowerShell has the correct CLRVersion, type:


    The value for CLRVersion must be 4.0 or higher to enable PowerShell to load .NET assemblies in scripts. If it is not, change it for both Windows PowerShell 32-bit and 64-bit versions as follows:

    1. Run NotePad as an administrator.
    2. Create a file with the following content.
      <?xml version="1.0"?> 
      	  <startup useLegacyV2RuntimeActivationPolicy="true"> 
      		   <supportedRuntime version="v4.0.30319"/> 
      		   <supportedRuntime version="v2.0.50727"/> 
    3. Choose File > Save As, name the file powershell.exe.config, and save it to the following locations:



    4. Close the PowerShell window, open a new one as administrator, and type $psversiontable to verify that the CLRVersion is correct.
  4. Close the PowerShell window and launch PowerShell using PsExec.exe as follows:
    1. Open a Command Prompt window as administrator.
    2. Navigate to the location of PsExec.exe and enter:

      PsExec.exe -i -u "NT AUTHORITY\NetworkService" C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell

    3. Click Agree to accept the PsExec.exe license agreement.
  5. Navigate to the Disaster Recovery tools folder in the StorageZones Controller installation folder:

    cd 'C:\inetpub\wwwroot\Citrix\StorageCenter\Tools\Disaster Recovery'

  6. Import the Recovery.psm1 module:

    Import-Module .\Recovery.psm1

  7. To create the recovery queue, enter: New-SCQueue -name recovery -operation recovery

    The output of that command includes the name of the queue created. For example: Queue 92736b5d-1cff-4760-92c8-d8b04dc92cb2 created

    To view the new folder, open a file browser and navigate to:

    \\server\Primary Storage Location\Queue. You will see the Queue folder, such as 92736b5d-1cff-4760-92c8-d8b04dc92cb2.

  8. Customize the recovery PowerShell script for your location, as described in the next section.

To customize the recovery PowerShell script for your location

The DoRecovery.ps1 PowerShell script is executed by the task scheduler to handle the recovery process. This file includes the file backup and storage locations which you must specify for your site.

  1. On the StorageZones Controller, navigate to the recovery PowerShell script:

    C:\inetpub\wwwroot\Citrix\StorageCenter\Tools\Disaster Recovery\DoRecovery.ps1

  2. Edit the script as follows:
    1. Set the $backupRoot parameter to point to the UNC path of your backup location. For example: $backupRoot = "\\\BackupLocation\persistentstorage"
    2. Set the $storageRoot parameter to point to the UNC path of your StorageZones Controller persistent storage. For example: $storageRoot = "\\\StorageLocation\persistentstorage"

To create and schedule a task for recovery

  1. Start Windows Task Scheduler and in the Actions pane click Create Task.
  2. On the General tab:
    1. Provide a meaningful Name for the task.
    2. Under Security options, click Change User or Group, and specify the user to run the task, either Network Service or a named user that has write permissions to the storage location.
    3. From the Configure for menu, select the operating system of the server where the task will be run.
  3. To create a trigger: On the Triggers tab, click New. Then, for Begin the task, choose On a schedule and specify a schedule.
  4. To create an action: On the Actions tab, click New.
    1. For Action, choose Start a program and specify the full path to the program. For example: C:\Windows\System32\cmd.exe.

      For Add arguments enter: /c "c:\windows\syswow64\WindowsPowerShell\v1.0\PowerShell.exe -File .\DoRecovery.ps1" >> .\recovery.log 2>>.\recoveryerror.log

    2. For Start in, specify the Disaster Recovery folder in the StorageZones Controller installation location. For example: c:\inetpub\wwwroot\Citrix\StorageCenter\Tools\Disaster Recovery

To test the recovery process

  1. Create a test file and upload it to ShareFile.
  2. After a hour or so, verify that the file appears in persistent storage (in the path specified for $backupRoot).
  3. Delete the file from ShareFile: In the ShareFile administrator tool, click Recycle Bin, select the file, and then click Delete Permanently.
  4. Delete the file from the persistent storage.

    This step recreates the action that ShareFile would perform 7 days after the file is deleted.

  5. In the ShareFile administrator tool, go to Admin > StorageZones, click the zone, and then click Recover Files.
  6. Click in the Recovery Date text box and select a date and time before the file was deleted and after it was uploaded.

    The file list for the StorageZone on the specified date and time appears.

  7. Select the check box for the file and then click Restore.
  8. Select the folder to contain the restored files and then click Restore.

    The Folder list shows a spinning icon to indicate that the file is added to the backup queue and is ready to be restored.

    Busy icon in folder list

  9. Recover the file:
    1. Open a Command Prompt window as administrator.
    2. Navigate to the location of PsExec.exe and enter:

      PsExec.exe -i -u "NT AUTHORITY\NetworkService" C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell

    3. In the PowerShell window, navigate to:

      cd 'C:\inetpub\wwwroot\Citrix\StorageCenter\Tools\Disaster Recovery'

    4. Run the recovery script:


    The PowerShell window will include the message "Item recovered". The file is added to the persistent storage location.

  10. Download the restored file from the ShareFile web site.

Related PowerShell commands

The following PowerShell commands support disaster recovery.

  • Get-RecoveryPendingFileIDs

    Gets the list of file IDs needed for recovery. For syntax and parameters, use this command:

    Get-Help Get-RecoveryPendingFileIDs -full

  • Set-RecoveryQueueItemsStatus

    Sets a status for all or specified items in the recovery queue. This overwrites the existing recovery status in the queue. For syntax and parameters, use this command:

    Get-Help Set-RecoveryQueueItemsStatus -full