5/1/2017 10:13:00 PM

The following Powershell script can be run or put on a schedule to regularly backup AWS EBS volumes.

Another option is to use an online service such as Stratus Tools (https://www.stratustools.net/)

$AWS_AccessKey = '############' $AWS_SecretKey = '####################################################################' $AWS_DefaultRegion = 'us-east-1' Set-AWSCredentials -AccessKey $AWS_AccessKey -SecretKey $AWS_SecretKey Set-DefaultAWSRegion $AWS_DefaultRegion # base description $description = 'BACKUP: ' + (Get-Date).ToString('yyyy-MM-dd') $dayOfTheWeek = (Get-Date).DayOfWeek #$dayOfTheWeek # an arry of volume Ids to backup $volumeIds = @( "vol-########" #SQL Data ) # only backup on Mondays if ($dayOfTheWeek -eq "Monday") { $volumeIds += "vol-########" #SQL Logs $volumeIds += "vol-################" #SQL Backups } # loop through all volume Ids for ($volumeIdIndex = 0; $volumeIdIndex -lt $volumeIds.Length; $volumeIdIndex++) { #"This is line number " + $volumeIdIndex $volumeId = $volumeIds[$volumeIdIndex] #set base snapshot description $snapshotDescription = $description + " - " + $volumeId #try to get volume details to get tag name $volumeDetails = Get-EC2Volume -VolumeId $volumeId #if ($volumeDetails.Tags.Length not null) #{ for ($tagIndex = 0; $tagIndex -lt $volumeDetails.Tags.Length; $tagIndex++) { #echo $volumeDetails.Tags[$tagIndex]; if ($volumeDetails.Tags[$tagIndex].Key -eq "Name") { $snapshotDescription = $snapshotDescription + " - " + $volumeDetails.Tags[$tagIndex].Value } } #} #$volumeId #$snapshotDescription New-EC2Snapshot -VolumeId $volumeId -Description $snapshotDescription }