Last active
August 29, 2015 14:18
-
-
Save Damovisa/db8bdeee993bd15639f0 to your computer and use it in GitHub Desktop.
Octopus Deploy Raven Import Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Raven Import Script | |
# You'll need a copy of Raven.Abstractions.dll, Raven.Client.Lightweight.dll, Jint.Raven.dll and Raven.Smuggler.exe | |
# in a lib folder (note: one more than the export script) under the location of this script. | |
# You can find them in the folder where Octopus Deploy is installed. | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$false,Position=1)] | |
[string]$importPath = ".\dump.raven", | |
[Parameter(Mandatory=$false)] | |
[string]$ravenUrl = "http://localhost:10931" | |
) | |
$importPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($importPath) | |
Add-Type -Path .\lib\Raven.Abstractions.dll | |
Add-Type -Path .\lib\Raven.Client.Lightweight.dll | |
Add-Type -Path .\lib\Jint.Raven.dll | |
try | |
{ | |
$smugglerpath = Convert-Path .\lib\Raven.Smuggler.exe | |
[Reflection.Assembly]::LoadFile($smugglerpath) | |
$asyncPath = Convert-Path .\lib\Microsoft.CompilerServices.AsyncTargetingPack.Net4.dll | |
[Reflection.Assembly]::LoadFile($asyncPath) | |
} | |
catch [System.Reflection.ReflectionTypeLoadException] | |
{ | |
Write-Host "Message: $($_.Exception.Message)" | |
Write-Host "StackTrace: $($_.Exception.StackTrace)" | |
Write-Host "LoaderExceptions: $($_.Exception.LoaderExceptions)" | |
} | |
$options = New-Object Raven.Abstractions.Smuggler.SmugglerOptions | |
$options.OperateOnTypes = [Raven.Abstractions.Smuggler.ItemType]::Documents -bor [Raven.Abstractions.Smuggler.ItemType]::Indexes | |
$options.Timeout = 3600000 | |
$encryptionFilter = New-Object Raven.Abstractions.Smuggler.FilterSetting | |
$encryptionFilter.Path = "@metadata.@id" | |
$encryptionFilter.Values = New-Object System.Collections.Generic.List[System.String] | |
$encryptionFilter.Values.Add("Raven/Encryption/Verification") | |
$options.Filters.Add($encryptionFilter) | |
$connection = New-Object Raven.Abstractions.Data.RavenConnectionStringOptions | |
$connection.Url = $ravenUrl | |
$connection.Credentials = [System.Net.CredentialCache]::DefaultCredentials | |
$smuggler = New-Object Raven.Smuggler.SmugglerApi($options, $connection) | |
$stream = New-Object System.IO.FileStream($importPath, [System.IO.FileMode]::Open) | |
$smuggler.ImportData($stream, $options) | |
$stream.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment