Backup Amazon EBS Volume Snapshots from Amazon Ec2
Data 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.
- 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.
- Assign Programmatic access type to the New User.
- Click on Attach existing policies directly and grant the user with policy AmazonEC2FullAccess.
- Click Next and Create a new user. Download AWS Access Key ID and Secret Access Key. These details will be used later.
Installing AWS Command Line Interface
We are using Ubuntu 14.04 machine for the demonstration. SSH to running Amazon Ec2 Ubuntu 14.04 instance and install awscli by using the below-listed command. Click Here for installing AWS CLI on other platforms of Linux.
sudo apt-get install 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 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.
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.
######## 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!