RavenDB - Smuggler - Moving Data between File Systems

Octopus.Script exported 2015-11-15 by timhunt303 belongs to ‘RavenDB’ category.

To move data directly between two instances (or different file systems in the same instance) using the between option introduced in Smuggler version 3.

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

Raven Smuggler Path

ravenSmugglerPath =

Full path to the Smuggler EXE.

For example: C:\RavenDB\Smuggler\Raven.Smuggler.exe

Source File System URL

sourceFileSystemURL = http://localhost:8080/

The URL of the Raven File System, where the Source File System is located.

For example: http://localhost:8080/

Name of the Source File System

sourceFileSystemName

Name of the Source File System in Raven.

Api Key for the Source File System

sourceFileSystemApiKey

API Key needed to access the Source File System.

If key is not provided, anonymous authentication will be used.

For more information: http://ravendb.net/docs/article-page/3.0/csharp/studio/accessing-studio

Destination File System URL

destinationFileSystemURL = http://localhost:8080/

The URL for the Raven File System where the Destination File System is located.

For example: http://localhost:8080/

Name of the Destination File System

destinationFileSystemName

Name of the Destination File System in Raven.

API Key for the Destination File System

destinationFileSystemAPIKey

API Key needed to access the Destination File System.

If key is not provided, anonymous authentication will be used.

For more information: http://ravendb.net/docs/article-page/3.0/csharp/studio/accessing-studio

Timeout

timeout = 300000

The timeout (in milliseconds) to use for requests.

Script body

Steps based on this template will execute the following PowerShell script.


# Variables

#Location of the Raven Smuggler exe
$ravenSmugglerPath = $OctopusParameters["ravenSmugglerPath"]


#--------------------------------------------------------------------
# Source File System Variables

#URL of RavenFS that is being backed up 
$sourceFileSystemURL = $OctopusParameters["sourceFileSystemURL"]

#name of the RavenFS that is being backed up
$sourceFileSystemName = $OctopusParameters["sourceFileSystemName"]

#API Key for the Source File System
$sourceFileSystemApiKey = $OctopusParameters["sourceFileSystemApiKey"]




#--------------------------------------------------------------------
#Destination File System Variables

#URL of destination RavenFS 
$destinationFileSystemURL = $OctopusParameters["destinationFileSystemURL"]

#Name of the destination RavenFS
$destinationFileSystemName = $OctopusParameters["destinationFileSystemName"]

#API Key for the Destination File System
$destinationFileSystemAPIKey = $OctopusParameters["destinationFileSystemAPIKey"]


#--------------------------------------------------------------------
# Other Variables retrieved from Octopus

#Get timeout variable
$timeout = $OctopusParameters["timeout"]



#--------------------------------------------------------------------

#checks to see if the entered file system exists, return a Boolean value depending on the outcome
function doesRavenFSExist([string] $FSChecking, [string]$URL)
{
    #retrieves the list of File Systems at the specified URL
    $fs_list = Invoke-RestMethod -Uri "$URL/fs" -Method Get
    #checks if the File System is at the specified URL
    if ($fs_list -contains $FSChecking.ToString()) 
    {
        return $TRUE
    }
    else 
    {
        return $FALSE
    }

    
}#ends does File System exist function


Write-Output "`n-------------------------`n"

#--------------------------------------------------------------------

#Check path to smuggler
Write-Output "Checking if Smuggler path is correct`n"

$smuggler_Exists = Test-Path -Path $ravenSmugglerPath



#if the path is correct, the script continues, throws an error if the path is wrong
If($smuggler_Exists -eq $TRUE)
{
    Write-Output "Smuggler exists"

}#ends if smuggler exists 
else
{
    Write-Error "Smuggler cannot be found `nCheck the directory: $ravenSmugglerPath" -ErrorId E4
    Exit 1
}#ends else, smuggler can't be found

Write-Output "`n-------------------------`n"

#--------------------------------------------------------------------
#Checking the version of smuggler

$SmugglerVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($ravenSmugglerPath).FileVersion

if($SmugglerVersion -cgt "3")
{
    Write-Host "Smuggler Version: $SmugglerVersion"
}
else
{
    Write-Error "The version of Smuggler that is installed can NOT complete this step. `nPlease update Smuggler before continuing" -ErrorId E4
    Exit 1
}
Write-Output "`n-------------------------`n"

#--------------------------------------------------------------------

#Check if Source File System and destination File System exists
Write-Output "Checking if both $sourceFileSystemName and $destinationFileSystemName exist`n"

$sourceFS_exists = doesRavenFSExist -FSChecking $sourceFileSystemName -URL $sourceFileSystemURL 

$DestinationFS_Exist = doesRavenFSExist -FSChecking $destinationFileSystemName -URL $destinationFileSystemURL


#if both File System exist a backup occurs
if(($sourceFS_exists -eq $TRUE) -and ($DestinationFS_Exist -eq $TRUE))
{

    Write-Output "Both $sourceFileSystemName and $destinationFileSystemName exist`n"

}#ends if 
#if the source File System doesn’t exist an error is throw
elseIf(($sourceFS_exists -eq $FALSE) -and ($DestinationFS_Exist -eq $TRUE))
{

    Write-Error "$sourceFileSystemName does not exist. `nMake sure the File System exists before continuing" -ErrorId E4
    Exit 1

}
#if the destination File System doesn’t exist an error is throw
elseIf(($DestinationFS_Exist -eq $FALSE) -and ($sourceFS_exists -eq $TRUE))
{

    Write-Error "$destinationFileSystemName does not exist. `nMake sure the File System exists before continuing" -ErrorId E4
    Exit 1

}#ends destination FS not exists
else
{
 
    Write-Error "Neither $sourceFileSystemName or $destinationFileSystemName exists. `nMake sure both File Systems exists" -ErrorId E4
    Exit 1

}#ends else

Write-Output "`n-------------------------`n"

#--------------------------------------------------------------------
#start Backup

try
{
    Write-Output "Attempting Backup up now"
    Write-Output "`n-------------------------`n"
    & $ravenSmugglerPath between $sourceFileSystemURL $destinationFileSystemURL --filesystem=$sourceFileSystemName --filesystem2=$destinationFileSystemName --api-key=$sourceFileSystemApiKey --api-key2=$destinationFileSystemAPIKey --timeout=$timeout
    Write-Output "`n-------------------------`n"
    Write-Output "Backup successful"


}#ends try
catch
{
    Write-Error "An error occurred during backup, please try again" -ErrorId E4
    Exit 1
}#ends catch

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "4ec55f5e-ab8b-409d-b404-dc0bf705d057",
  "Name": "RavenDB - Smuggler - Moving Data between File Systems",
  "Description": "To move data directly between two instances (or different file systems in the same instance) using the between option introduced in Smuggler version 3.",
  "Version": 0,
  "ExportedAt": "2015-11-15T22:06:33.737+00:00",
  "ActionType": "Octopus.Script",
  "Author": "timhunt303",
  "Parameters": [
    {
      "Name": "ravenSmugglerPath",
      "Label": "Raven Smuggler Path",
      "HelpText": "Full path to the Smuggler EXE.\n\nFor example: **C:\\RavenDB\\Smuggler\\Raven.Smuggler.exe**",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "sourceFileSystemURL",
      "Label": "Source File System URL",
      "HelpText": "The URL of the Raven File System, where the **Source File System** is located.\n\nFor example: **http://localhost:8080/**",
      "DefaultValue": "http://localhost:8080/",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "sourceFileSystemName",
      "Label": "Name of the Source File System",
      "HelpText": "Name of the **Source File System** in Raven.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "sourceFileSystemApiKey",
      "Label": "Api Key for the Source File System",
      "HelpText": "API Key needed to access the **Source File System**.\n\nIf key is not provided, anonymous authentication will be used. \n\nFor more information: http://ravendb.net/docs/article-page/3.0/csharp/studio/accessing-studio",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "Sensitive"
      }
    },
    {
      "Name": "destinationFileSystemURL",
      "Label": "Destination File System URL",
      "HelpText": "The URL for the Raven File System where the **Destination File System** is located.\n\nFor example: **http://localhost:8080/**",
      "DefaultValue": "http://localhost:8080/",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "destinationFileSystemName",
      "Label": "Name of the Destination File System",
      "HelpText": "Name of the **Destination File System** in Raven.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "destinationFileSystemAPIKey",
      "Label": "API Key for the Destination File System",
      "HelpText": "API Key needed to access the **Destination File System**.\n\nIf key is not provided, anonymous authentication will be used.\n\nFor more information: http://ravendb.net/docs/article-page/3.0/csharp/studio/accessing-studio",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "Sensitive"
      }
    },
    {
      "Name": "timeout",
      "Label": "Timeout",
      "HelpText": "The timeout (in milliseconds) to use for requests.",
      "DefaultValue": "300000",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptBody": "\n# Variables\n\n#Location of the Raven Smuggler exe\n$ravenSmugglerPath = $OctopusParameters[\"ravenSmugglerPath\"]\n\n\n#--------------------------------------------------------------------\n# Source File System Variables\n\n#URL of RavenFS that is being backed up \n$sourceFileSystemURL = $OctopusParameters[\"sourceFileSystemURL\"]\n\n#name of the RavenFS that is being backed up\n$sourceFileSystemName = $OctopusParameters[\"sourceFileSystemName\"]\n\n#API Key for the Source File System\n$sourceFileSystemApiKey = $OctopusParameters[\"sourceFileSystemApiKey\"]\n\n\n\n\n#--------------------------------------------------------------------\n#Destination File System Variables\n\n#URL of destination RavenFS \n$destinationFileSystemURL = $OctopusParameters[\"destinationFileSystemURL\"]\n\n#Name of the destination RavenFS\n$destinationFileSystemName = $OctopusParameters[\"destinationFileSystemName\"]\n\n#API Key for the Destination File System\n$destinationFileSystemAPIKey = $OctopusParameters[\"destinationFileSystemAPIKey\"]\n\n\n#--------------------------------------------------------------------\n# Other Variables retrieved from Octopus\n\n#Get timeout variable\n$timeout = $OctopusParameters[\"timeout\"]\n\n\n\n#--------------------------------------------------------------------\n\n#checks to see if the entered file system exists, return a Boolean value depending on the outcome\nfunction doesRavenFSExist([string] $FSChecking, [string]$URL)\n{\n    #retrieves the list of File Systems at the specified URL\n    $fs_list = Invoke-RestMethod -Uri \"$URL/fs\" -Method Get\n    #checks if the File System is at the specified URL\n    if ($fs_list -contains $FSChecking.ToString()) \n    {\n        return $TRUE\n    }\n    else \n    {\n        return $FALSE\n    }\n\n    \n}#ends does File System exist function\n\n\nWrite-Output \"`n-------------------------`n\"\n\n#--------------------------------------------------------------------\n\n#Check path to smuggler\nWrite-Output \"Checking if Smuggler path is correct`n\"\n\n$smuggler_Exists = Test-Path -Path $ravenSmugglerPath\n\n\n\n#if the path is correct, the script continues, throws an error if the path is wrong\nIf($smuggler_Exists -eq $TRUE)\n{\n    Write-Output \"Smuggler exists\"\n\n}#ends if smuggler exists \nelse\n{\n    Write-Error \"Smuggler cannot be found `nCheck the directory: $ravenSmugglerPath\" -ErrorId E4\n    Exit 1\n}#ends else, smuggler can't be found\n\nWrite-Output \"`n-------------------------`n\"\n\n#--------------------------------------------------------------------\n#Checking the version of smuggler\n\n$SmugglerVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($ravenSmugglerPath).FileVersion\n\nif($SmugglerVersion -cgt \"3\")\n{\n    Write-Host \"Smuggler Version: $SmugglerVersion\"\n}\nelse\n{\n    Write-Error \"The version of Smuggler that is installed can NOT complete this step. `nPlease update Smuggler before continuing\" -ErrorId E4\n    Exit 1\n}\nWrite-Output \"`n-------------------------`n\"\n\n#--------------------------------------------------------------------\n\n#Check if Source File System and destination File System exists\nWrite-Output \"Checking if both $sourceFileSystemName and $destinationFileSystemName exist`n\"\n\n$sourceFS_exists = doesRavenFSExist -FSChecking $sourceFileSystemName -URL $sourceFileSystemURL \n\n$DestinationFS_Exist = doesRavenFSExist -FSChecking $destinationFileSystemName -URL $destinationFileSystemURL\n\n\n#if both File System exist a backup occurs\nif(($sourceFS_exists -eq $TRUE) -and ($DestinationFS_Exist -eq $TRUE))\n{\n\n    Write-Output \"Both $sourceFileSystemName and $destinationFileSystemName exist`n\"\n\n}#ends if \n#if the source File System doesn’t exist an error is throw\nelseIf(($sourceFS_exists -eq $FALSE) -and ($DestinationFS_Exist -eq $TRUE))\n{\n\n    Write-Error \"$sourceFileSystemName does not exist. `nMake sure the File System exists before continuing\" -ErrorId E4\n    Exit 1\n\n}\n#if the destination File System doesn’t exist an error is throw\nelseIf(($DestinationFS_Exist -eq $FALSE) -and ($sourceFS_exists -eq $TRUE))\n{\n\n    Write-Error \"$destinationFileSystemName does not exist. `nMake sure the File System exists before continuing\" -ErrorId E4\n    Exit 1\n\n}#ends destination FS not exists\nelse\n{\n \n    Write-Error \"Neither $sourceFileSystemName or $destinationFileSystemName exists. `nMake sure both File Systems exists\" -ErrorId E4\n    Exit 1\n\n}#ends else\n\nWrite-Output \"`n-------------------------`n\"\n\n#--------------------------------------------------------------------\n#start Backup\n\ntry\n{\n    Write-Output \"Attempting Backup up now\"\n    Write-Output \"`n-------------------------`n\"\n    & $ravenSmugglerPath between $sourceFileSystemURL $destinationFileSystemURL --filesystem=$sourceFileSystemName --filesystem2=$destinationFileSystemName --api-key=$sourceFileSystemApiKey --api-key2=$destinationFileSystemAPIKey --timeout=$timeout\n    Write-Output \"`n-------------------------`n\"\n    Write-Output \"Backup successful\"\n\n\n}#ends try\ncatch\n{\n    Write-Error \"An error occurred during backup, please try again\" -ErrorId E4\n    Exit 1\n}#ends catch\n"
  },
  "Category": "RavenDB",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/ravendb-smuggler-move-data-between-filesystems.json",
  "Website": "/step-templates/4ec55f5e-ab8b-409d-b404-dc0bf705d057",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRF0Y6OjR8iHx8fW1la0szNmVZZZB8k5crLkIyMwl1evI6QwrCw6uPjsiAh////8/HxjiSEkQAABNlJREFUeNrs24uWmyAUBVBQkKfh//+2gKiYGKMRsWkPnbUmdZLUPfeBEUoe/8gggAACCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggADy/0GceDpgpDSM/SCE9L1SxMweK5swWu/5rdQKlDAUmTCmbZqkYb9UIzZR+p4INxxishlHa1xViBNC7H0Lo5RZvrafBrHDIdY2maUixJ+L2v0W/nxfD41D2cRtsiHtXwAhzz9aQlSMj1CvlDantLYSxPeevRArRHZW/cBymWR0LoJSOirHi51sZ9103lml9GooONssKdUhhszN9CEI2apWn1pJmqdXP7zELtKraVlliHot563ZfQyZJYQo6hV0CtOTpDG1IfRACoqeqrxrJMpwzC0hTVsT4vTTTJFlmf0YH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tgi+ktkLb0/tK7utYV4bhlZi/brG6DyPK74m+BOHnVO+M/iwECCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggAACSM3xR4ABAI1fHCI0qDDgAAAAAElFTkSuQmCC",
  "$Meta": {
    "Type": "ActionTemplate"
  }
}

History

Page updated on Sunday, November 15, 2015