ata is the most important factor in any business and taking its backup on a regular interval of time is a handsome practice. We have come up the technique to auto backup Amazon EBS volume snapshots from running Amazon Ec2 instance using AWS CLI.
Prerequisite
- Amazon AWS account for creating Access key ID and Secret access key.
- Running Amazon Ec2 Instance.
- AWS Command Line Interface.
Create Access key ID and Secret access key
- Log in to your Amazon Dashboard Console Account.
- Click on IAM management console.
- Click on ADD Users to create a new user for backing up EBS Volume.
Installing AWS Command Line Interface
We are using centos7 machine for the demonstration
python –version
curl “https://bootstrap.pypa.io/get-pip.py” -o “get-pip.py”
python get-pip.py
pip -V
pip install awscli
pip install –upgrade awscli
Configure AWS CLI on Linux
After installing awscli, there is a requirement of configuring awscli on Amazon Ec2 instance. Hit command aws configure and Enter the AWS Access Key ID, AWS Secret Access Key, and Default region name when prompted. Default output format can be left blank.
aws configure
AWS Access Key ID [None]: AKIAIUARU2RSR74GQRXA AWS Secret Access Key [None]: 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 Default region name [None]: us-east-1 Default output format [None]:
We are done with all the Prerequisite, now we will go ahead and schedule auto backups for Amazon EBS volume from Amazon Ec2 instances using awscli.
Auto Backup Amazon EBS Volumes From Amazon Ec2
Use the below command to create a snapshot of Amazon EBS volume from Ec2 Instance. Enter your EBS volume ID for which you want to take backup or create a snapshot and give a right description message.
Command
aws ec2 create-snapshot --volume-id vol-xxxxxxxx --description "Relevant description Message"
How to obtain the EBS volume ID
Log into AWS Dashboard >> Clicking on service Ec2 >> Select the Ec2 instance >> Choose Block Device
Apply Cronjob to Auto Backup Snapshots of Amazon EBS.
crontab -e
######## Automating EBS Volume Snapshots ######## 00 09 * * * aws ec2 create-snapshot --volume-id vol-0234f278482d2e197 --description "Disk Backup for Linux Together Demo Server"
This brings an end to the tutorial. In the above tutorial, we have elaborated the technique to backup Amazon EBS volume using awscli. Write down your questions and queries in the comment section. Do like and share the share the blog, We will be back with more interesting tutorials asap. Thanks!
Recent Comments