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! 🔄
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.
- 🚀 Automatically backs up files uploaded to the source bucket.
- 🧑💻 Uses AWS Lambda for automation.
- 💸 Cost-effective and easy to set up.
Before you begin, ensure you have:
- AWS Account with access to AWS Lambda and S3.
- IAM Role with permissions for Lambda to access S3.
Follow these steps to set up the automated backup system:
- Go to the S3 Console in AWS.
- Create a Source Bucket (e.g.,
my-source-bucket
). - Create a Backup Bucket (e.g.,
my-backup-bucket
).
- Go to the Lambda Console and click Create Function.
- Choose Author from Scratch.
- Name your function (e.g.,
FileBackupLambda
). - Select Python 3.x as the runtime.
- Click Create Function.
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.
Set up an event to trigger Lambda when a new file is uploaded:
- Go to the S3 Console and select your source bucket.
- Under Properties, find Event notifications.
- Create a new event notification and select Lambda function as the destination.
- Choose your Lambda function (
FileBackupLambda
). - Set the event type to All object create events.
- Upload a file to your source bucket.
- Check the backup bucket for the file.
- View AWS Lambda Logs in CloudWatch to verify everything is working!
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.
- Go to CloudWatch Console.
- Find the Logs section and locate your Lambda function’s log group.
- Review logs to track successful backups or any errors.
- 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.