Upload Backup Files to Amazon S3

  • Alex Marsh

    Old Hand

    Points: 311

    Comments posted to this topic are about the item Upload Backup Files to Amazon S3

  • MARIA JOSE CASCALES

    SSC Enthusiast

    Points: 119

    Alex Marsh - Monday, October 20, 2014 9:12 AM

    Comments posted to this topic are about the item Upload Backup Files to Amazon S3

    Hi! thank you for you script, it helps a lot in my issue. 
    I have had a problem, It doesn't load by default the AWSPowerShell module (you can modify your ps profile for loading it,but...) .
    I decide to create an script with params 
    * Create CopyFilesToS3.ps1
       param([string]$BucketName="?",[string]$AccessKey="?",[string]$secretKey="?",[string]$region="?",[string]$filename="?")
       Set-ExecutionPolicy RemoteSigned
       Import-Module "{your-path}\AWSPowerShell.psd1"
       Write-S3Object -BucketName $BucketName -AccessKey $AccessKey -secretKey $secretKey -Region $region -File $filename -key $filename
    And call it 

        SET @cmd = 'powershell .\CopyFilesToS3.ps1'
        SET @cmd += ' -BucketName "' + @AWSbucketName;
        SET @cmd += '" -AccessKey "' + @AWSAccessKey;
        SET @cmd += '" -secretKey "' + @AWSSecretKey;
        SET @cmd += '" -Region "' + @AWSregion;   
        SET @psCmd = @cmd + '" -File "' + @fileName + '" -key "' + @fileName+'"';
        exec xp_cmdshell @psCmd;

  • Alex Marsh

    Old Hand

    Points: 311

    Been a while since I had to use this, and recently found myself back doing this sort of thing. The script failed with the message "The term 'Get-S3Object' is not recognized as the name of a cmdlet, ...." etc.
    The issue is a missing file called "SQLPS.exe.config" in C:\Program Files (x86)\Microsoft SQL Server\<version>\Tools\Binn
    Contents is pretty simple:
    <?xml version="1.0"?>
    <configuration>
      <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>
        <supportedRuntime version="v2.0.50727"/>
      </startup>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <probing privatePath="ManagementStudio" />
        </assemblyBinding>
      </runtime>
    </configuration>

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply