ShareFile consist out of two different storage location, the Citrix Managed and the Customer Managed. The first one, the Citrix Managed storage location is hosted by Citrix in their public cloud. The second one, the Customer Managed storage location is hosted by the customer in his own datacenter. In this article I’ll go into the backup and restore procedures for the Customer Managed StorageZone.
Recycle Bin / Retention
Before I’ll go into the backup and restore process, let me clarify how ShareFile processes deleted files and folder. Every file being uploaded to ShareFile is registered in the ShareFile Metadata. In case of a customer managed StorageZone, the ShareFile cloud only contains the metadata, but not the actual files. These files are stored within your datacenter. When a file or folder is deleted from ShareFile it will be kept in the recycle bin for 7 days, within these 7 days its very easy to recover files. After 7 days the deleted files and folder are purged from the recycle bin and permanently deleted from the persistent storage folder. Unfortunately the 7 days recycle bin retention time cannot be changed, it’s hard coded.
The 7 Days Recycle Bin retention time is hardcoded at this time
By default the metadata for deleted files will be kept for 3 year by Citrix. Although you are not able to change this value yourself, Citrix can increase this value if needed for legal compliance. If you do need to restore data, after 7 days, you’ll need a on-site backup solution. So let’s start with the ShareFile back-up.
Backup
On your customer managed StorageZone, all data is located on a CIFS Share which should be accessible by all StorageZone Controllers. You will need to backup the persistent storage location once a day or according to your own backup requirements. Depending on the environment this can be quite a large amount of data which needs to be backed up. A daily full backup probably isn’t the best approach, I would suggest using incrementals.
Backup your persistentstorage folder, preferable using incremental backups
Although the CIFS Share being used contains several folders, only the persistentstorage folder needs to be backed up!
Recovery Queue
Before files and folder can be restored, the StorageZone controller need a one-time preparation, a recovery queue needs to be created. For additional information take a look at the eDocs “Prepare StorageZones Controller for file recovery“, but roughly this needs to be done:
- On the StorageZones Controller, run PowerShell as an administrator
- Change the PowerShell execution policy to RemoteSigned : Set-ExecutionPolicy RemoteSigned
- Verify the CLRVersion is at least 4.0 : $psversiontable
- Run PowerShell using the “Network Service” account, which can be accomplished with Sysinternals PsExec : PsExec.exe -i -u “NT AUTHORITY\NetworkService” C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell
- Browse to the disaster recovery folder: cd ‘C:\inetpub\wwwroot\Citrix\StorageCenter\Tools\Disaster Recovery’
- Import the ShareFile recovery module : Import-Module .\Recovery.psm1
- Create a recovery queu : New-SCQueue -name recovery -operation recovery
After creating the recovery queue we need to customize the PowerShell recovery script.
Recovery Script
The recovery script “DoRecovery.ps1” contains two important variables which need to be configured:
- $backupRoot
- $storageRoot
The $BackupRoot variable should contain the backup location, which can be used to restore data. In our case this is the Veeam server, where we mount backups. Keep in mind you need to grant the “Network Service” account access to this location. The DoRecovery.ps1 script will be executed as “Network Service” .
Grant the “Network Service” account access to the $backupRoot location
The second variable, $StorageRoot should contain the StorageZone location used by the StorageZone Controller. Now everything is in place we can start restoring files and folder which where deleted more than 7 days ago
Restore Files & Folders
To select the file(s) and folder(s) which should be restored we first need to log-in to the ShareFile account. Select Admin > StorageZones > Select the customer managed storagezone > Click “Recover Files”.
The Recovery screen will display your accounts metadata and allows you to select the files and files which need to be recovered. Start by selecting the desired data, then the needed files and folder, last you click Restore.
Next you need to select the location within ShareFile where the files will be restored. The folder which are marked red can’t be selected to restore files. It’s also not possible to overwrite existing folders!
Operation in Progress “Recover”
After selecting the files and folders which need to be restored, the selected content is visible in ShareFile right away. If you take a closer look at the files you’ll notice a spinning icon on the right side, which reports “Operation in Progress”. Although the files are visible at this point we are only seeing the metadata, the underlying files aren’t available yet.
Recover Queue
Soon as the Restore Button is clicked the ShareFile Recovery procedure starts and the Recovery queue, which we created earlier, is filled with files.
The file name within the queue does not relate to the actual files being restore, it’s just a recovery job, which contains all the necessary information to recover the files. If you need the actual file name being restored from the backup just open the file with notepad. The file contains all kinds of useful info, including the FileID for the files which is going to be restored.
Now that the recover queue on the StorageZone controller is filled with one or more recovery jobs we are able to start the recovery process.
DoRecovery.ps1
For ShareFile to start the recovery process we need to run the script DoRecovery.ps1, which also needs to run under the “Network Service” account. To accomplish this you’ll need to :
- Open a command prompt as administrator
- Start PowerShell under the “Network Service”account : PsExec.exe -i -u “NT AUTHORITY\NetworkService” C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell
- Browse to the Recovery folder : cd ‘C:\inetpub\wwwroot\Citrix\StorageCenter\Tools\Disaster Recovery’
- Run the Recovery script : .\DoRecovery.ps1
The recovery process will start importing the deleted files from the backup location to the persistent storage folder. When the DoRecovery.ps1 script finishes the files are available in your ShareFile environment again.
Summary
Although the process to recover deleted files in ShareFile works fine, it takes quite some steps to get the data back into the customer manages StorageZone. It’s not something you would want to do on a daily basis. I certainly hope the ShareFile team is going to change the hard coded Recycle Bin retention time in the nearby future, so we are able to dramatically increase the retention value. Sure, a large Recycle Bin retention time will increase the CIFS share size, but in my opinion this does not outweigh the effort needed to recover files from backup.