Created
October 21, 2014 21:23
-
-
Save iperdomo/10c7eddf15482814962f to your computer and use it in GitHub Desktop.
Backup S3 data
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 | |
set -e | |
CFG="${1}" # akvo-flow-server-config repo clone | |
BKP="${2}" # backup folder | |
LST="/tmp/instances.txt" # list of instances | |
rm -rf "${LST}" | |
cd "${CFG}" | |
git pull origin master | |
find "${CFG}" -name 'appengine-web.xml' -exec sed -nr 's/(.*)"s3bucket" value="(.*)"(.*)/\2/p' {} >> "${LST}" \; | |
for i in $(sort -u "${LST}"); do | |
echo $i | |
mkdir -p "${BKP}/${i}" | |
aws s3 sync "s3://${i}" "${BKP}/${i}" | |
done |
Seems I can't leave a comment against a line with a Gist.
For line #7, it's better to use mktemp just in case the script is running twice at the same time. I know it shouldn't but better safe than sorry.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
# Usage ./backup.sh /path/to/akvo-flow-server-config /path/to/backup