Skip to content

Instantly share code, notes, and snippets.

@ygerasimov
Created June 22, 2017 08:49
Show Gist options
  • Save ygerasimov/0b10533094a025611a88bf3c744975e6 to your computer and use it in GitHub Desktop.
Save ygerasimov/0b10533094a025611a88bf3c744975e6 to your computer and use it in GitHub Desktop.
Backtrac.io snippet to test single environment. Wait for snapshot to complete before deploy.
#!/bin/bash
# Written in bash
# echo $SHELL
# change these values
APIKEY='8AAABBBCCC5'
PROJECTID='111222'
nid=`curl -sS --header "x-api-key: $APIKEY" --request POST https://backtrac.io/api/project/$PROJECTID/snapshot | sed 's/.*\"nid\":\"\([^\"]*\).*/\1/'`
echo "Snapshot started: $nid"
printf "Waiting..."
i=0
while true
do
success=`curl -sS --header "x-api-key: $APIKEY" --request GET https://backtrac.io/api/result/$nid | grep completed`
# echo "CURL RESPONSE: $success END"
if [ "$success" != "" ] || [ $i -eq 60 ]
then
break
fi
sleep 20
printf '.'
i=$((i+1))
done
echo 'Production snapshot completed.'
###### NOW RUN ALL YOUR DEPLOYMENT OPERATIONS ######
##### Like: deploy code, update database, clear caches etc. #######
# Run another snapshot after release is done.
curl --header "x-api-key: $APIKEY" --request POST "https://backtrac.io/api/project/$PROJECTID/compare_itself"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment