Last active
August 29, 2015 14:06
-
-
Save Twinuma/c8f25aa4fcd26fc5af19 to your computer and use it in GitHub Desktop.
RDS自動Snapshot取得シェル
This file contains hidden or 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
AWSAccessKeyId=your AccessKey | |
AWSSecretKey=your SecretKey |
This file contains hidden or 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/sh -l | |
export JAVA_HOME=/usr/lib/jvm/jre | |
export AWS_BIN=/opt/aws/bin | |
export PATH=$PATH:$EC2_HOME/bin:$AWS_BIN | |
export EC2_REGION=ap-northeast-1 | |
export AWS_CREDENTIAL_FILE=/opt/aws/rds/credential.txt | |
BACKUP_DATE=`date '+%Y%m%d'` | |
rds-create-db-snapshot -i YOUR DBNAME -s backup-$BACKUP_DATE | |
COUNT=0 | |
# 世代をここで設定 | |
MAX=3 | |
for i in `rds-describe-db-snapshots | cut -f3 -d ' ' | sort -r` | |
do | |
if [ $COUNT -ge $MAX ] | |
then | |
echo "DELETE:$i" | |
rds-delete-db-snapshot $i -f | |
fi | |
COUNT=`expr $COUNT + 1` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment