0

I'm currently using the package dest to create a backup of a site as follows:

msdeploy.exe -source:appHostConfig="Default Web Site",computerName="https://server:8172/MSDeploy.axd?site=Default Web Site",userName="abc",password="xyz",authtype="basic" 
-dest:package="c:\backup\backup-2011.8.2.1000.zip" -verb:sync

Here, the destination is a local file. Is it possible to make the target a location on the remote server itself? I'm running the command from my build server, but I'd like the backup to be created and stored on the remote server instead of being downloaded to the build machine.

This will be running against a public server, so shared folders are out of the question. What other options do I have?

1 Answer 1

0

Yes, with a -source:runCommand, but first you should put the script there (a batch for example)

from: http://sourcecodebean.com/archives/synchronizing-files-and-executing-commands-on-a-remote-server-using-msdeploy/775 Bellow is a simple PowerShell script that has two functions. Send-Files – Synchronizes a local folder to a remote server. Execute-RemoteCommand – Executes a batch file on a remote server. The file must already be in place on the server.

$MSDeployExe = "C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe"
$RemoteHost = "http://localhost:80/MsDeployAgentService"
$Credentials = ""
$LocalDir = "C:\temp\LocalDir"
$RemoteDir = "C:\temp\RemoteDir"

function Send-Files {
        param (
                [string]$WebDeployService,
                [string]$LocalDir,
                [string]$RemoteDir,
                [string]$Credentials
        )

        Write-Host "Sending files to $WebDeployService`: $RemoteDir" -ForegroundColor Yellow

        if ($Credentials -ne "") {
                $Credentials = ",getCredentials=" + $Credentials
        }

        & $MSDeployExe "-verb:sync" "-source:dirPath=$LocalDir" "-dest:dirPath=$RemoteDir,computername=$WebDeployService$Credentials" "-verbose"
        $successful = $?

        if (-not $successful) {
                throw "Failed sending files"
        }
}

function Execute-RemoteCommand {
        param (
                [string]$WebDeployService,
                [string]$RemoteDir,
                [string]$BatchFile,
                [string]$Credentials,
                [int]$waitInterval = 15000
        )

        $command = Join-Path $RemoteDir $BatchFile
        Write-Host "Executing $command on $WebDeployService" -ForegroundColor Yellow

        & $MSDeployExe "-verb:sync" "-source:runCommand=’$command’,waitInterval=$waitInterval,waitAttempts=1" "-dest:auto,computername=$RemoteHost$Credentials" "-verbose"

        $successful = $?

        if (-not $successful) {
                throw "Failed executing command"
        }
}

# Test
Send-Files $RemoteHost $LocalDir $RemoteDir $Credentials
Execute-RemoteCommand $RemoteHost $RemoteDir "HelloWorld.bat" $Credentials

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .