Last active
August 29, 2015 14:08
-
-
Save jahil/c369b375f837f840bec4 to your computer and use it in GitHub Desktop.
EBS Backup and Rotation Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export EC2_PRIVATE_KEY=~/.ec2/pk.pem | |
export EC2_CERT=~/.ec2/cert.pem | |
ec2-create-snapshot vol-ab0921c0 -d "Intellinar Server ROOT - $(date +'%d-%m-%Y')" | |
ec2-create-snapshot vol-110d257a -d "Intellinar Data - $(date +'%d-%m-%Y')" | |
ec2-create-snapshot vol-8bbb93e0 -d "Database Server aka RDS - $(date +'%d-%m-%Y')" | |
Purge EBS Snapshots | |
------------------- | |
export EC2_PRIVATE_KEY=~/.ec2/pk.pem | |
export EC2_CERT=~/.ec2/cert.pem | |
ec2-describe-snapshots | sort -r -k 5 | sed 1,7d | awk '{print "Deleting snapshot: " $2}; system("ec2-delete-snapshot " $2)' | |
'''' | |
{ | |
"Statement": [ | |
{ | |
"Sid": "Stmt1311252614644", | |
"Action": [ | |
"ec2:CreateSnapshot", | |
"ec2:CreateTags", | |
"ec2:CreateVolume", | |
"ec2:DeleteSnapshot", | |
"ec2:DeleteTags", | |
"ec2:DescribeInstances", | |
"ec2:DescribeSnapshotAttribute", | |
"ec2:DescribeSnapshots", | |
"ec2:DescribeTags", | |
"ec2:DescribeVolumes" | |
], | |
"Effect": "Allow", | |
"Resource": "*" | |
} | |
] | |
} | |
'''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment