Skip to content

datawithyashvi/automated-backup-s3-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Automated Backup System Using AWS S3 and Lambda 🚀

This repository contains an automated backup system that uses AWS S3 and AWS Lambda to automatically copy files uploaded to one S3 bucket (source bucket) to another S3 bucket (backup bucket). This ensures your data is safely backed up every time a new file is added! 🔄

Table of Contents

Overview 🌟

This system automates file backups using AWS services. The Lambda function is triggered automatically whenever a new file is uploaded to the source S3 bucket, and it copies the file to the backup bucket.

Features:

  • 🚀 Automatically backs up files uploaded to the source bucket.
  • 🧑‍💻 Uses AWS Lambda for automation.
  • 💸 Cost-effective and easy to set up.

Architecture 🏗️

System Architecture

Prerequisites 🛠️

Before you begin, ensure you have:

  • AWS Account with access to AWS Lambda and S3.
  • IAM Role with permissions for Lambda to access S3.

Setup Instructions 📝

Follow these steps to set up the automated backup system:

Step 1: Create AWS S3 Buckets 🪣

  1. Go to the S3 Console in AWS.
  2. Create a Source Bucket (e.g., my-source-bucket).
  3. Create a Backup Bucket (e.g., my-backup-bucket).

Step 2: Create Lambda Function 🖥️

  1. Go to the Lambda Console and click Create Function.
  2. Choose Author from Scratch.
  3. Name your function (e.g., FileBackupLambda).
  4. Select Python 3.x as the runtime.
  5. Click Create Function.

Step 3: Write Lambda Function Code ✍️

Lambda function

Step 4: Set IAM Role Permissions 🔑

Create an IAM Role with these permissions:

  • AmazonS3ReadOnlyAccess: Access to the source bucket.
  • AmazonS3FullAccess: Write permissions for the backup bucket.

Assign the role to your Lambda function.

Step 5: Configure S3 Event Notification 🔔

Set up an event to trigger Lambda when a new file is uploaded:

  1. Go to the S3 Console and select your source bucket.
  2. Under Properties, find Event notifications.
  3. Create a new event notification and select Lambda function as the destination.
  4. Choose your Lambda function (FileBackupLambda).
  5. Set the event type to All object create events.

Step 6: Test the System ✅

  1. Upload a file to your source bucket.
  2. Check the backup bucket for the file.
  3. View AWS Lambda Logs in CloudWatch to verify everything is working!

Usage ⚙️

Once set up, any new file uploaded to the source bucket is automatically copied to the backup bucket. Monitor the Lambda function's execution via CloudWatch Logs.

Monitoring and Logs 📊

  1. Go to CloudWatch Console.
  2. Find the Logs section and locate your Lambda function’s log group.
  3. Review logs to track successful backups or any errors.

Notes:

  • Versioning: Enable versioning in the backup bucket for multiple file versions.
  • Notifications: Set up notifications to alert you about backup success or errors.
  • Encryption: Consider enabling encryption on your backup bucket for extra security.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages