Shell Script to auto make AMI backup and delete old backups.
- You need install AWS tools at your system.
You can use yum install aws* to install all require packages.
And please make sure your AWS tools install path is same with this script path. - Please use "env | grep EC2_HOME" to find out your system's setting.
- Please use "env | grep JAVA_HOME" to find out your system's setting.
- Please add IAM role with appropriate permissions and launch instance with this IAM Role.
If you are not familiar with IAM Role, you can create a admin IAM Role for quick use.
- region: Reference http://docs.aws.amazon.com/general/latest/gr/rande.html
- instanceID: You can find your instance ID at AWS Manage Console
- amiNamePrefix: Your prefer AMI name prefix
- amiDescription: Your prefer AMI description
- routine: If you want to keep 7 days AMI backups, please set this variable true otherwise set it false.
- If you set routine false, this script will delete all your exist AMIs and Snapshots.
- If you set routine true, AMI name will be $amiNamePrefix+$weekday.
for example, if you set $amiNamePrefix as "My AMI Backup " and set routine true.
then your AMI name will be "My AMI Backup Mon" (without quotation marks).
If you use none Amazon Linux, please visit: https://github.com/henrychen95/AWS-AMI-Auto-Backup-None-Amazon-Linux