Shell script for backup ec2 with ami and cross region replica fork from https://github.com/pavlops/aws-ami-backups
This script starts from the script of https://github.com/pavlops/aws-ami-backups but has been improved in these points:
-
Removed the InstanceId parameter and the Identifier parameter
-
Backs up all hooks in running state and those in stopped state with the tag backup_if_stopped = True
-
Create a replica in eu-central-1 (or you must change line 111)
Requirements:
Ec2 must be in eu-west-1 or you have to change the line 111Ec2 source region can be setup in variable $sourceregion- Replica is in eu-central-1
(or you must change line 111)Ora change variable $destregion - The server from which it is launched must have the aws profile configured
- Aws cli
Usage:
./aws-ec2-ami-backup-replica.sh retentiondays profile
A future version will also support the region
UPDATE 09/06/2021
- Added support for choosing regions in variable
- Added search for instances with tag value backup_if_stopped True or true
- Added deleting old images from destination region
SCRIPT aws-ec2-ami-backup-REGION-replica.sh
Same as before script but with possibility to choose source and destination region in parameter ($3 and $4)