Created
June 6, 2017 13:09
-
-
Save clok/e129e0ce8514f256ad9bc788b6d6505b to your computer and use it in GitHub Desktop.
Snowplow ES backup sync to S3
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
# m h dom mon dow command | |
0 * * * * /usr/sbin/es-dump | |
30 * * * * /usr/sbin/es-dump-s3-sync | |
45 0 * * * find /elasticsearch/backup/ -mtime +7 -delete |
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/bash | |
DUMP_FILE=/elasticsearch/backup/`date +%s` | |
elasticdump \ | |
--input=http://localhost:9200/good \ | |
--output=$ \ | |
| gzip > $DUMP_FILE.json.gz |
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/bash | |
IAM_PROFILE=`wget -q -O - http://169.254.169.254/latest/meta-data/iam/info | jq -r .InstanceProfileArn | cut -d '/' -f 2` | |
echo $IAM_PROFILE | |
case $IAM_PROFILE in | |
"staging-snowplow-elasticsearch") | |
S3_BUCKET=staging-backups-bucket | |
;; | |
"production-snowplow-elasticsearch") | |
S3_BUCKET=production-backups-bucket | |
;; | |
*) | |
echo "please assign one of the following IAM roles to back up es dumps to s3\nstaging-snowplow-elasticsearch\nproduction-snowplow-elasticsearch" | |
echo "staging-snowplow-elasticsearch" | |
echo "production-snowplow-elasticsearch" | |
exit 1 | |
;; | |
esac | |
echo $S3_BUCKET | |
aws s3 sync /elasticsearch/backup/ s3://$S3_BUCKET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment