Skip to content

Instantly share code, notes, and snippets.

@Damovisa
Last active December 16, 2015 23:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Damovisa/34ef3a589a63f687281e to your computer and use it in GitHub Desktop.
Save Damovisa/34ef3a589a63f687281e to your computer and use it in GitHub Desktop.
Octopus Deploy Raven Export Script
# Raven Export Script
# You'll need a copy of Raven.Abstractions.dll, Raven.Client.Lightweight.dll,
# Microsoft.CompilerServices.AsyncTargetingPack.Net4.dll, and Raven.Smuggler.exe in a lib folder
# 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]$exportPath = ".\dump.raven",
[Parameter(Mandatory=$false)]
[string]$ravenUrl = "http://localhost:10931"
)
$exportPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($exportPath)
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)"
}
Add-Type -Path .\lib\Raven.Abstractions.dll
Add-Type -Path .\lib\Raven.Client.Lightweight.dll
$options = New-Object Raven.Abstractions.Smuggler.SmugglerOptions
$options.OperateOnTypes = [Raven.Abstractions.Smuggler.ItemType]::Documents -bor [Raven.Abstractions.Smuggler.ItemType]::Indexes
$options.Timeout = 3600000
$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($exportPath, [System.IO.FileMode]::Create)
$smuggler.ExportData($stream, $options, $false, $false, $null)
$stream.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment