Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
dont start stopped apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Heavybullets8 committed Aug 20, 2023
1 parent 3dafaf0 commit 77bf74b
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions functions/backup_restore/database/cnpg_dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,15 @@ backup_cnpg_databases() {
db_dump_stopped=true
fi

# Store the current replica counts for all deployments in the app before scaling down
declare -A original_replicas=()
mapfile -t replica_lines < <(get_current_replica_counts "$app_name" | jq -r 'to_entries | .[] | "\(.key)=\(.value)"')
for line in "${replica_lines[@]}"; do
read -r key value <<< "$(echo "$line" | tr '=' ' ')"
original_replicas["$key"]=$value
done
if [[ $db_dump_stopped == true ]]; then
# Store the current replica counts for all deployments in the app before scaling down
declare -A original_replicas=()
mapfile -t replica_lines < <(get_current_replica_counts "$app_name" | jq -r 'to_entries | .[] | "\(.key)=\(.value)"')
for line in "${replica_lines[@]}"; do
read -r key value <<< "$(echo "$line" | tr '=' ' ')"
original_replicas["$key"]=$value
done
fi

for deployment in "${!original_replicas[@]}"; do
if [[ ${original_replicas[$deployment]} -ne 0 ]]; then
Expand All @@ -205,12 +207,13 @@ backup_cnpg_databases() {
continue
fi

# Scale the resources back to the original replica counts
for deployment in "${!original_replicas[@]}"; do
if [[ ${original_replicas[$deployment]} -ne 0 ]]; then
scale_resources "$app_name" 300 "${original_replicas[$deployment]}" "$deployment" > /dev/null 2>&1
fi
done
if [[ $db_dump_stopped == true ]]; then
for deployment in "${!original_replicas[@]}"; do
if [[ ${original_replicas[$deployment]} -ne 0 ]]; then
scale_resources "$app_name" 300 "${original_replicas[$deployment]}" "$deployment" > /dev/null 2>&1
fi
done
fi

done

Expand Down

0 comments on commit 77bf74b

Please sign in to comment.