Skip to content

Commit

Permalink
[PLAT-8624] Metrics not populated after yugabundle restore
Browse files Browse the repository at this point in the history
Summary:
Issue when restoring from yugabundle to yba-installer with prometheus metrics. Swamper target files
were not getting copied over properly. This diff fixes that by copying the targets explicitly over
from the yugabackup directory (where we untar yugabundle backup) to the correct location. This is
normally not a problem for backup restore because we untar directly in the destination so those
files get written.

Test Plan:
try yugabundle -> yba-installer backup/restore and verify swamper targets exist with right
permissions and metrics show up in UI
Verify same for yba-installer -> yba-installer

Reviewers: sanketh, dshubin

Reviewed By: dshubin

Subscribers: jenkins-bot, yugaware

Differential Revision: https://phabricator.dev.yugabyte.com/D24877
  • Loading branch information
mchiddy committed Apr 28, 2023
1 parent e0cf909 commit 612fe27
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions managed/devops/bin/yb_platform_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,14 @@ restore_backup() {
modify_service yb-platform stop

db_backup_path="${destination}/${PLATFORM_DUMP_FNAME}"
yugabackup="${destination}"/"${YUGABUNDLE_BACKUP_DIR}"
trap 'delete_db_backup ${db_backup_path}' RETURN
tar_cmd="tar -xzf"
if [[ "${verbose}" = true ]]; then
tar_cmd="tar -xzvf"
fi
if [[ "${yugabundle}" = true ]]; then
# Copy over yugabundle backup data into the correct yba-installer paths
yugabackup="${destination}"/"${YUGABUNDLE_BACKUP_DIR}"
db_backup_path="${yugabackup}"/"${PLATFORM_DUMP_FNAME}"
rm -rf "${yugabackup}"
mkdir -p "${yugabackup}"
Expand Down Expand Up @@ -615,11 +615,15 @@ restore_backup() {
modify_service prometheus stop
run_sudo_cmd "rm -rf ${PROMETHEUS_DATA_DIR}/*"
if [[ "${yba_installer}" = true ]] && [[ "${yugabundle}" = true ]]; then
run_sudo_cmd "mv ${destination}/${YUGABUNDLE_BACKUP_DIR}/${PROMETHEUS_SNAPSHOT_DIR}/*/* \
run_sudo_cmd "mv ${yugabackup}/${PROMETHEUS_SNAPSHOT_DIR}/*/* \
${PROMETHEUS_DATA_DIR}"
backup_targets=$(find "${yugabackup}" -name swamper_targets -type d)
run_sudo_cmd "cp -Tr ${backup_targets} ${destination}/data/prometheus/swamper_targets"
run_sudo_cmd "chown -R ${yba_user}:${yba_user} ${destination}/data/prometheus"
elif [[ "${yba_installer}" = true ]]; then
run_sudo_cmd "mv ${destination}/${PROMETHEUS_SNAPSHOT_DIR}/*/* ${PROMETHEUS_DATA_DIR}"
run_sudo_cmd "rm -rf ${destination}/${PROMETHEUS_SNAPSHOT_DIR}"
run_sudo_cmd "chown -R ${yba_user}:${yba_user} ${destination}/data/prometheus"
else
run_sudo_cmd "mv ${destination}/${PROMETHEUS_SNAPSHOT_DIR}/* ${PROMETHEUS_DATA_DIR}"
fi
Expand Down

0 comments on commit 612fe27

Please sign in to comment.