As you may have observed already , when a RDS instance is deleted all the automated snapshots disappear along with it giving us little or no option to recover. However, manual snapshots can be retained indefinitely for a additional cost.
You will then realize that AWS has imposed a softlimit of 100 manual snapshots per region and account . This can be extended by speaking to AWS but this will cause the cost to increase over a period of time. There is also the other downside, were snapshots can't be moved to a S3 bucket.
After much discussuion we decided to delete the manual snapshots older than 10 days.
Attached is the sample script.
$20Days = (Get-Date).Adddays(-20)
$ManulSonpshot = Get-RDSDBSnapshot -Region us-east-1 | Sort-Object SnapshotCreateTime | select -First 1000 | Where-Object {$_.SnapshotType -eq "manual" -and $_.SnapshotCreateTime -le $20Days } | Select-Object DBInstanceIdentifier , Engine , SnapshotCreateTime ,dbsnapshotidentifier
foreach ($ManulSonpshot_loop in $ManulSonpshot)
{
Remove-RDSDBSnapshot -Region us-east-1 -DBSnapshotIdentifier $ManulSonpshot_loop.DBSnapshotIdentifier -Force
Write-Host ' Deleted snapshot ' $ManulSonpshot_loop.DBInstanceIdentifier + '-'+ $ManulSonpshot_loop.DBSnapshotIdentifier
}
You will then realize that AWS has imposed a softlimit of 100 manual snapshots per region and account . This can be extended by speaking to AWS but this will cause the cost to increase over a period of time. There is also the other downside, were snapshots can't be moved to a S3 bucket.
After much discussuion we decided to delete the manual snapshots older than 10 days.
Attached is the sample script.
$20Days = (Get-Date).Adddays(-20)
$ManulSonpshot = Get-RDSDBSnapshot -Region us-east-1 | Sort-Object SnapshotCreateTime | select -First 1000 | Where-Object {$_.SnapshotType -eq "manual" -and $_.SnapshotCreateTime -le $20Days } | Select-Object DBInstanceIdentifier , Engine , SnapshotCreateTime ,dbsnapshotidentifier
foreach ($ManulSonpshot_loop in $ManulSonpshot)
{
Remove-RDSDBSnapshot -Region us-east-1 -DBSnapshotIdentifier $ManulSonpshot_loop.DBSnapshotIdentifier -Force
Write-Host ' Deleted snapshot ' $ManulSonpshot_loop.DBInstanceIdentifier + '-'+ $ManulSonpshot_loop.DBSnapshotIdentifier
}
This blog nicely explain how to delete RDS snapshot manual. This is really very helpful information.
ReplyDeleteacinen_ta Angie Andrews https://wakelet.com/wake/bUT9NR7OpX5vVcD8dTC2o
ReplyDeletecurekdedoub