Hi Guys,
Can anybody help to fix this issue I have followed below script to take SQL backup from AWS Windows server to move to S3 bucket. Partially PS script is working fine until taking backup and store in server but facing error to move to S3.
$server = ‘.’
$database = ‘MyDatabase’
$s3Bucket = ‘s3-sql-backups’
$backupPath = 'C:\SqlBackup'
$region = ‘eu-west-1’
accessKey and secretKey can be removed if running on an EC2 instance and using IAM roles for security
$accessKey = ‘USER-ACCESS-KEY’
$secretKey = ‘USER-SECRET-KEY’
$timestamp = get-date -format yyyyMMddHHmmss
$fileName = “$database-$timestamp.bak”
$filePath = Join-Path $backupPath $fileName
Backup-SqlDatabase -ServerInstance $server -Database $database -BackupFile $filePath
AccessKey and SecretKey can be removed if running on an EC2 instance and using IAM roles for security
Write-S3Object -BucketName $s3Bucket -File $filePath -Key $fileName -Region $region -AccessKey $accessKey -SecretKey $secretKey
Remove-Item $backupPath$database*.bak
Error Description:
Write-S3Object : Name resolution failure attempting to reach service in region us-east-1 (as supplied to the -Region parameter or
from configured shell default).
The remote server returned an error: (403) Forbidden…
Possible causes:
- The region may be incorrectly specified (did you specify an availability zone?).
- The service may not be available in the region.
- No network connectivity.
See AWS service endpoints - AWS General Reference for the latest service availability across the AWS regions.
At C:\Users\xxxx\Desktop\Backup-Script-2.ps1:19 char:1
- Write-S3Object -BucketName $s3Bucket -File $filePath -Key $fileName - …
-
- CategoryInfo : NotSpecified: ( [Write-S3Object], Exception
- FullyQualifiedErrorId : System.Exception,Amazon.PowerShell.Cmdlets.S3.WriteS3ObjectCmdlet
Thanks,
MM