@@ -7,7 +7,7 @@ if [ -n "${DEBUG:-}" ]; then
77fi
88
99function confirm() {
10- read -p " $1 [y/n] " confirmation
10+ read -r - p " $1 [y/n] " confirmation
1111 if [ " $confirmation " != " y" ]; then
1212 echo " Canceled. 😅"
1313 exit
@@ -26,8 +26,7 @@ function reset() {
2626 # we're targeting a valid tag here. Do this early in order to fail fast.
2727 if [ -n " $version " ]; then
2828 set +e
29- git rev-parse --verify --quiet " refs/tags/$version " > /dev/null
30- if [ $? -gt 0 ]; then
29+ if ! git rev-parse --verify --quiet " refs/tags/$version " > /dev/null; then
3130 echo " Bad version: $version "
3231 exit
3332 fi
@@ -43,12 +42,15 @@ function reset() {
4342 echo " Okay ... good luck! 😰"
4443 fi
4544
45+ # assert that commands are defined
46+ : " ${dc:? } " " ${cmd:? } "
47+
4648 # Hit the reset button.
4749 $dc down --volumes --remove-orphans --rmi local
4850
4951 # Remove any remaining (likely external) volumes with name matching 'sentry-.*'.
5052 for volume in $( docker volume list --format ' {{ .Name }}' | grep ' ^sentry-' ) ; do
51- docker volume remove $volume > /dev/null &&
53+ docker volume remove " $volume " > /dev/null &&
5254 echo " Removed volume: $volume " ||
5355 echo " Skipped volume: $volume "
5456 done
@@ -60,30 +62,34 @@ function reset() {
6062}
6163
6264function backup() {
65+ local type
66+
6367 type=${1:- " global" }
64- touch $( pwd ) /sentry/backup.json
65- chmod 666 $( pwd ) /sentry/backup.json
66- $dc run -v $( pwd ) /sentry:/sentry-data/backup --rm -T -e SENTRY_LOG_LEVEL=CRITICAL web export $type /sentry-data/backup/backup.json
68+ touch " ${PWD} /sentry/backup.json"
69+ chmod 666 " ${PWD} /sentry/backup.json"
70+ $dc run -v " ${PWD} /sentry:/sentry-data/backup" --rm -T -e SENTRY_LOG_LEVEL=CRITICAL web export " $type " /sentry-data/backup/backup.json
6771}
6872
6973function restore() {
70- type=${1:- " global" }
71- $dc run --rm -T web import $type /etc/sentry/backup.json
74+ local type
75+
76+ type=" ${1:- global} "
77+ $dc run --rm -T web import " $type " /etc/sentry/backup.json
7278}
7379
7480# Needed variables to source error-handling script
7581MINIMIZE_DOWNTIME=" ${MINIMIZE_DOWNTIME:- } "
76- STOP_TIMEOUT=60
82+ export STOP_TIMEOUT=60
7783
7884# Save logs in order to send envelope to Sentry
79- log_file=sentry_ " ${cmd%% * } " _log-$( date +' %Y-%m-%d_%H-%M-%S' ) .txt
85+ log_file=" sentry_ ${cmd%% * } _log-$( date +%Y-%m-%d_%H-%M-%S) .txt"
8086exec & > >( tee -a " $log_file " )
8187version=" "
8288
8389while (( $# )) ; do
8490 case " $1 " in
85- --report-self-hosted-issues) REPORT_SELF_HOSTED_ISSUES=1 ;;
86- --no-report-self-hosted-issues) REPORT_SELF_HOSTED_ISSUES=0 ;;
91+ --report-self-hosted-issues) export REPORT_SELF_HOSTED_ISSUES=1 ;;
92+ --no-report-self-hosted-issues) export REPORT_SELF_HOSTED_ISSUES=0 ;;
8793 * ) version=$1 ;;
8894 esac
8995 shift
0 commit comments