Skip to content

Instantly share code, notes, and snippets.

@iperdomo
Created October 21, 2014 21:23
Show Gist options
  • Save iperdomo/10c7eddf15482814962f to your computer and use it in GitHub Desktop.
Save iperdomo/10c7eddf15482814962f to your computer and use it in GitHub Desktop.
Backup S3 data
#!/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
@iperdomo
Copy link
Author

# Usage
./backup.sh /path/to/akvo-flow-server-config /path/to/backup

@carlio
Copy link

carlio commented Oct 22, 2014

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