• TechOps

    Need clarity?
    Chat with our experts now

    • Web Hosting SupportWeb Hosting Support
    • Helpdesk Support

      Skilled and professional 24/7 helpdesk support

    • Product Support

      Boost your product support with our expertise

    • Managed ServicesManaged Services
    • Server Management

      Don't let server issues slow you down. Let us manage them for you

    • Server Monitoring

      Safeguard your server health with our comprehensive monitoring solutions

    • Staff AugmentationStaff Augmentation
    • Hire an Admin

      Transform your business operations with our expert administrative support

    • Hire a Team

      Augment your workforce with highly skilled professional from our diverse talent pool

  • CloudOps

    Confused?
    Discuss with our sales team now.

    • Author ProfileAWS
      Well Architected Review
    • Author ProfileFinOps As a Service

      FinOps As a Service

    • Migrate

      Upgrade the journey: Migrate & Modernize seamlessly

    • Modernize

      Effortless CloudOps mastery for seamless cloud management

    • Optimize

      Efficient CloudOps: Boosting performance through optimization

    • Manage

      Simplify compliance complexities with our dedicated service

  • DevOps

    How Supportsages
    is creating an
    impact?

    View Casestudies
    • Author Profile24/7 DevOps As a Service

      Round-the-clock DevOps for uninterrupted efficiency

    • Author ProfileCI/CD Pipeline

      Automated CI/CD pipeline for seamless deployments

    • Author ProfileInfrastructure As a Code

      Crafting infrastructure with ingenious code

    • Author ProfileDevSecOps

      Integrated security in continuous DevOps practices

    • Author ProfileHire DevOps Engineers

      Level up your team with DevOps visionaries

    • Author ProfileConsulting Services

      Navigate success with expert DevOps consulting

  • SecOps

    Expert SecOps Services
    for any Scale

    • Author ProfileVAPT

      Vulnerability Assessment and Penetration Testing

    • Author ProfileSource Code Review

      Ensuring source code security and safe practices to reduce risks

    • Author ProfileSecurity Consultation

      On demand services for improving server security

    • Author ProfileSystem Hardening

      Reduced vulnerability and proactive protection

    • Author ProfileManaged SOC

      Monitors and maintains system security. Quick response on incidents

    • Author ProfileCompliance as a Service

      Regulatory compliance, reduced risk

  • Insights

    Explore our latest
    insights and resources

    Blog

    Explore our latest articles and insights

    Case Studies

    Read about our client success stories

  • Contact Us

  • About
  • Certifications
  • Life at Supportsages
  • Events
  • Contact
  • Careers
  • Blog

  • Dedicated Support Team
  • Quasi-dedicated Support Team
  • Hire a DevOps Engineer
  • Hire a Billing Support Staff
  • Per-ticket Support Plan
  • Managed Services

  • Microsoft Azure Expert
  • AWS Cloud Expert
  • Hire a developer
SS

SupportSages

Bites of wisdom @ work


Copyright © 2008 - 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy

How to take RDS Snapshots using Lambda?

Smith Nevil
  • 2 min read
How to take RDS Snapshots using Lambda?

Generating audio, please wait...

Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a relational database in the cloud. It provides cost-efficient, resizable capacity and can manage common database administration tasks. If your site/application stores its sensitive data in the database, you will definitely want to back up that information so that it can be restored in case of any disaster.

Manual backups for RDS can be configured and scheduled. Thought of doing it the lambda way and below is a working script for the same. Code is originally developed by another author and shared at https://gist.github.com/mzupan/41d01bfb3b4c292fdac0

Below is the python code. The Lambda function is set to run every day using CloudWatch Event Scheduler. All we did was to create a trigger by connecting a CloudWatch event, where it is set up as a cron command, to the Lambda function.

The retention period is set as 7 days and also change the DBInstance identifier as the one in your RDS instance. Below code worked at the time of writing, but if it is not, please comment below.

import

boto3

import datetime

def lambda_handler(event, context):

print("Connecting to RDS")

client = boto3.client('rds')

print("RDS snapshot backups stated at %s...\n" %

datetime.datetime.now())

client.create_db_snapshot(

DBInstanceIdentifier='web-platform-slave',

DBSnapshotIdentifier='web-platform-%s' %

datetime.datetime.now().strftime("%y-%m-%d-%H"),

Tags=[

{

'Key': 'CostCenter',

'Value': 'web'

},

]

)

for snapshot in

client.describe_db_snapshots(DBInstanceIdentifier='web-platform-slave',

MaxRecords=50)['DBSnapshots']:

if create_ts < datetime.datetime.now() -

datetime.timedelta(days=7):

print "Deleting snapshot id:", snapshot['DBSnapshotIdentifier']

client.delete_db_snapshot(

DBSnapshotIdentifier=snapshot['DBSnapshotIdentifier']

)

This is my solution to take RDS Snapshots using Lambda.

Infrastructure operations are quite complex and require a high level of technical competency. Our team of specially trained infrastructure consultants provides expert cloud infrastructure management for all levels of operations.

 

  • Backup management
  • Sever management

Looking for AWS Experts?

We provide top-of-the-line custom AWS setup services tailored to your needs.

How to take RDS Snapshots using Lambda?

Acronis Backup Cloud on On-Premise Server

Acronis Backup Cloud on On-Premise Server
  • Backup management
  • Linux
logo

Automating AWS Infrastructure and services

Automating AWS Infrastructure and services
  • server
logo

cPanel: Find Duplicate Domains in Servers

cPanel: Find Duplicate Domains in Servers
  • cPanel
  • Sever management
logo

How to find DIMM errors and replace the faulty RAM ?

How to find DIMM errors and replace the faulty RAM ?
  • server
logo
Posts by Smith Nevil

Smith is always ready to learn new technologies and explore new territories. His never-ending passion towards technological advancements, unyielding affinity to perfection and excitement in the exploration of new areas, help him to be on the top of everything he is involved with. He is currently working as System Engineer at SupportSages.