Skip to content

Commit

Permalink
#619 add replica task
Browse files Browse the repository at this point in the history
  • Loading branch information
tillkuhn committed Feb 4, 2024
1 parent 8477af7 commit a3255af
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 5 additions & 0 deletions terraform/files/appctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ if [[ "$*" == *backup-db* ]]; then
PGPASSWORD=$APPCTL_DB_PASSWORD pg_dump -F p -c --no-owner -h "$db_host" -U "$DB_USERNAME" "$DB_USERNAME" >"$dumpfile"
dumpfile_basename=$(basename "$dumpfile")
aws s3 cp --storage-class STANDARD_IA "$dumpfile" "s3://${BUCKET_NAME}/backup/db/history/$dumpfile_basename"

replica_info=$(echo "$APPCTL_REPLICA_DB_URL"|cut -d@ -f2)
logit "Replicating to $replica_info from $dumpfile"
psql -d "${APPCTL_REPLICA_DB_URL}" <"$dumpfile" >"${WORKDIR}/backup/db/${APPID}_replica.log" 2>&1

logit "Creating custom formatted latest backup $dumpfile_latest + upload to s3://$BUCKET_NAME"
PGPASSWORD=$APPCTL_DB_PASSWORD pg_dump -h "$db_host" -U "$DB_USERNAME" "$DB_USERNAME" -Z2 -Fc > "$dumpfile_latest"
dumpfile_latest_basename=$(basename "$dumpfile_latest")
Expand Down
19 changes: 10 additions & 9 deletions terraform/main_objects.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ locals {
sonar_token = var.sonar_token
sonar_password = var.sonar_password
#docker_token = var.docker_token
docker_user = data.hcp_vault_secrets_app.ci_secrets_manual.secrets["DOCKER_USERNAME"]
imprint_url = var.imprint_url
instance_id = module.ec2.instance_id
mapbox_access_token = var.mapbox_access_token
tours_api_base_url = var.tours_api_base_url
tours_api_user_id = var.tours_api_user_id
photos_feed_url = var.photos_feed_url
oauth2_client_id = module.cognito.app_client_id
oauth2_client_name = module.cognito.app_client_name
docker_user = data.hcp_vault_secrets_app.ci_secrets_manual.secrets["DOCKER_USERNAME"]
appctl_replica_db_url = data.hcp_vault_secrets_app.ci_secrets_manual.secrets["APPCTL_REPLICA_DB_URL"]
imprint_url = var.imprint_url
instance_id = module.ec2.instance_id
mapbox_access_token = var.mapbox_access_token
tours_api_base_url = var.tours_api_base_url
tours_api_user_id = var.tours_api_user_id
photos_feed_url = var.photos_feed_url
oauth2_client_id = module.cognito.app_client_id
oauth2_client_name = module.cognito.app_client_name
# oauth2_client_secret = module.cognito.app_client_secret # move to HCP Secrets
oauth2_issuer_uri = module.cognito.pool_issuer_uri
oauth2_pool_domain = module.cognito.pool_domain
Expand Down
1 change: 1 addition & 0 deletions terraform/templates/.env_config
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ REMINDABOT_KAFKA_GROUP_ID=${remindabot_kafka_group_id}
# Configure appctl controller script
# DB PW for backups
APPCTL_DB_PASSWORD=${appctl_db_password}
APPCTL_REPLICA_DB_URL=${appctl_replica_db_url}
# DOCKER_USER used as image prefix in docker-compose.yml
DOCKER_USER=${docker_user}

Expand Down

0 comments on commit a3255af

Please sign in to comment.