100 Days of AWS — Day 19- Backup Solution using S3, Glacier and VPC Endpoint

  1. Create an IAM Role
  • Under Permissions policies search for AmazonS3FullAccess and click on Next
  • Give your role some meaningful name and click on Create role
  • Choose the IAM Role, you have create in previous step and click on Save.
  • Give your endpoint some name and under Services search for S3 and select the VPC. Keep all the other setting default and click on Create endpoint.
  • Give Lifecycle rule some name. Click on Move current versions of objects between storage classes and under Choose storage class transitions select Standard-IA and Days after object creation to 30 and Glacier Deep Archive to 90. This rule will move the object from S3 standard class to Standard-IA after 30 days and Glacier Deep Archive after 90 days.
# aws s3 cp /var/log/messages s3://plakhera-test-sts-bucketupload: ../var/log/messages to s3://plakhera-test-sts-bucket/messages
  • Now I am going to write a simple script which is going to sync data from your local folder to s3 bucket every minute
# cat /usr/bin/awss3sync.sh
aws s3 sync /var/log/. s3://plakhera-test-sts-bucket
  • Put that script in crontab so that it will execute every min
[root@ip-172-31-31-68 bin]# crontab -l*/1 * * * * /usr/bin/awss3sync.sh
  • Dont forget to change the permission of the script
# chmod +x /usr/bin/awss3sync.sh
  • Your simple backup solution is ready, it’s not a perfect solution but it’s easy to implement and will perform the given task.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Prashant Lakhera

Prashant Lakhera

AWS Community Builder, Ex-Redhat, Author, Blogger, YouTuber, RHCA, RHCDS, RHCE, Docker Certified,4XAWS, CCNA, MCP, Certified Jenkins, Terraform Certified, 1XGCP