Skip to content

Commit 51c7a24

Browse files
committed
fix: Added timeout for snapshot delete action to complete
1 parent 9f35ce6 commit 51c7a24

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

infrastructure/backups/backup.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,21 @@ docker run --rm \
220220
echo ""
221221
echo "Delete all currently existing snapshots"
222222
echo ""
223+
# Get list of snapshots as a simple array
224+
snapshots=$(docker run --rm --network="$NETWORK" appropriate/curl \
225+
-s "http://$(elasticsearch_host)/_snapshot/ocrvs/_all" | jq -r '.snapshots[].snapshot' || true)
226+
echo "Found snapshots:"
227+
echo "$snapshots" | sed 's/^/ - /'
228+
229+
for snap in $snapshots; do
230+
echo "Deleting snapshot: $snap"
231+
docker run --rm --network="$NETWORK" appropriate/curl \
232+
-s -X DELETE -H "Content-Type: application/json;charset=UTF-8" \
233+
"http://$(elasticsearch_host)/_snapshot/ocrvs/${snap}?wait_for_completion=true&pretty"
234+
done
223235
docker run --rm --network=$NETWORK appropriate/curl curl -sS -X DELETE -H "Content-Type: application/json;charset=UTF-8" "http://$(elasticsearch_host)/_snapshot/ocrvs"
224-
236+
echo "Waiting for snapshots to be removed"
237+
sleep 30
225238
#-------------------------------------------------------------------------------------
226239
echo ""
227240
echo "Register backup folder as an Elasticsearch repository for backing up the search data"

0 commit comments

Comments
 (0)