Josiah Sansone

Mass Restore of EPDM Cold Stored Files

Discussion created by Josiah Sansone on Feb 19, 2016
Latest reply on Mar 31, 2016 by Rodney Michels

If you've ever had an EPDM vault which either intentionally or accidentally cold stored a lot of files, you know it can be a pain to get them back.  EPDM includes no functionality for restoring multiple Cold-Stored files at once.  This can be an issue especially in a replicated environment if files are cold-stored on one archive before being replicated, then you end up with files that cannot replicate.  So, I came up with a solution.  In the spirit of sharing, here is a Powershell script I wrote which will perform a mass restore of any cold storage archive or archives.  Note that you need to customize lines 3 and 5 with your cold storage locations and your archive path, and you will also need to clear all pertinent rows from the ColdStorage table in SQL once you've run this script. I will discuss that more below.  I have used this twice and it has worked flawlessly both times.

NOTE: USE AT YOUR OWN RISK AND BACKUP BACKUP BACKUP and TEST TEST TEST before running this on a production vault.  This is only intended for users with a very strong knowledge of EPDM, SQL, and Powershell.  This is informational only and I take no responsibility for anyone using this on their own vault without proper testing and validation.

 

#BEGINSCRIPT

 

$ColdStores = @()

#Add all cold storage locations to $Coldstores as array below, like "C:\VaultNameColdStored\ColdStoreSchemaName\Date"

$ColdStores = @("Cold Storage Location 1","Cold Storage Location 2","Cold Storage Location 3")

#Set $ArchivePath to the archive root of the vault to which files are being restored - include trailing backslash!

$ArchivePath = "Vault Archive Path Here"

Foreach ($Store in $ColdStores)

{

    $dir = dir $store | ? {$_.PSISContainer}

    foreach ($d in $dir)

        {

        $name = $d.Fullname

        $folder = $d.name

        $destPath = $ArchivePath + $folder[-1] + "\" + $folder + "\"

        $indexpath = $destpath + "index.xml"

        IF (Test-Path $indexpath)

            {   

            [xml]$xmlfile = Get-Content $indexpath

            $Extension = [System.IO.Path]::GetExtension($xmlfile.index.filename)

            (Get-Content $indexpath) -replace " status=`"archived`"", "" | Set-Content $indexpath

            $files = Get-ChildItem $name | where {! $_.PSISContainer}

            foreach ($file in $files)

                {

                $dest = $destpath + $file.name + $Extension

                Write-Host "Copying $($file.name)$($Extension)"

                $file | Copy-Item -Destination $dest -Force

                }

            }

        }

}

 

#ENDSCRIPT

 

Paste the above script into a PS1 file and customize the two lines for the cold storage path and the vault archive path.  Again, backup and test thoroughly before running this. Once it's run, you can delete all rows from the dbo.ColdStorage table in SQL for the Cold Storage media which you restored.  If you did not restore all Cold Storage locations, only delete the rows for the Cold Storage Media that you restored!

Please feel free to ask any questions.

Cheers,

Josiah

Outcomes