AWS Lambda to create a RDS Sanpshot
import boto3
import datetime
def lambda_handler(event, context):
client = boto3.client('rds')
response = client.describe_db_instances()
for dba in response['DBInstances']:
backup_name = 'backup-' + (dba['DBInstanceIdentifier'] + '-%s') % datetime.datetime.now().strftime("%y-%m-%d-%H-%M")
client.create_db_snapshot(
DBInstanceIdentifier=dba['DBInstanceIdentifier'],
DBSnapshotIdentifier= backup_name,
Tags=[
{
'Key': 'BackupType',
'Value': 'long-term'
},
]
)
print(backup_name+ "Snapshot Created")
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment