This topic contains 2 replies, has 2 voices, and was last updated by
December 27, 2018 at 12:04 pm #131556ParticipantPoints: 18Rank: Member
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
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..
– 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 https://docs.aws.amazon.com/general/latest/gr/rande.html 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
December 27, 2018 at 1:52 pm #131672ParticipantPoints: 1,109Rank: Community Hero
have you checked whatever mentioned in the error ?
December 28, 2018 at 12:09 pm #131777ParticipantPoints: 18Rank: Member
I believe found the root cause of the error. Actually Windows EC2 instance is in domain and in Pvt. IP so it wont dont have internet to connect S3 bucket thats we got this error. I can tried in NON-Domain server and we can copy data to S3 bucket.
Now I need also how we can Zip 4GB .bak file and send mail notification once successful backup has done along with above script.
You must be logged in to reply to this topic.