Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.