Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Backup all instances
- for region in $(euca-describe-regions |grep -Ev "ATTACHMENT" |cut -f2);do
- export EC2_REGION=$region
- for volid in $(euca-describe-volumes |grep -Ev "ATTACHMENT" |cut -f2);do
- echo "Creating snapshot from $volid in $region";
- euca-create-snapshot $volid
- done;
- done;
- is_older()
- {
- DATE=$(date -d "$1" +%Y-%m-%d)
- TODAY=$(date -d "$(date +%Y-%m-%d) $2 $3 $4 $5" +%s)
- COMPARE=$(date -d "$DATE" +%s)
- test $(($TODAY - $COMPARE)) -le 0 && return 1 || return 0
- }
- #Purge old records
- for region in $(euca-describe-regions |grep -Ev "ATTACHMENT" |cut -f2);do
- export EC2_REGION=$region
- for snapid in $(euca-describe-snapshots |grep -Ev "ATTACHMENT"| cut -f2 );do
- snapdate=$(euca-describe-snapshots $snapid | cut -f5 | cut -d "T" -f1)
- echo "Getting snapshot $snapid in $region at $snapdate";
- if is_older $snapdate -7 days ;then
- echo "Purging snapshot $snapid in $region";
- euca-delete-snapshot $snapid
- fi
- sleep 1
- done;
- done;
Advertisement
Add Comment
Please, Sign In to add comment