Merge pull request #411 from github/enterprise-3.6-backport-312-djdefi-host-info

Backport 312 for 3.6: Capture backup host info in backup output
This commit is contained in:
Devin Dooley 2023-07-18 18:27:13 -07:00 коммит произвёл GitHub
Родитель 3376a0da97 81a7c1c9a9
Коммит cbb7d75097
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 37 добавлений и 0 удалений

Просмотреть файл

@ -151,6 +151,30 @@ if [ -n "$GHE_ALLOW_REPLICA_BACKUP" ]; then
echo "Warning: backing up a high availability replica may result in inconsistent or unreliable backups."
fi
# Output system information of the backup host
# If /etc/issue.net exists, use it to get the OS version
if [ -f /etc/issue.net ]; then
echo "Running on: $(cat /etc/issue.net)"
else
echo "Running on: Unknown OS"
fi
# If nproc command exists, use it to get the number of CPUs
if command -v nproc >/dev/null 2>&1; then
echo "CPUs: $(nproc)"
else
echo "CPUs: Unknown"
fi
# If the free command exists, use it to get the memory details
if command -v free >/dev/null 2>&1; then
echo "Memory $(free -m | grep '^Mem:' | awk '{print "total/used/free+share/buff/cache: " $2 "/" $3 "/" $4 "+" $5 "/" $6 "/" $7}')"
else
echo "Memory: Unknown"
fi
# Log backup start message in /var/log/syslog on remote instance
ghe_remote_logger "Starting backup from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP ..."

Просмотреть файл

@ -649,3 +649,16 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older"
done
)
end_test
# Check that information on system where backup-utils is installed is collected
begin_test "ghe-backup collects information on system where backup-utils is installed"
(
set -e
output=$(ghe-backup)
echo "$output" | grep "Running on: $(cat /etc/issue.net)"
echo "$output" | grep "CPUs: $(nproc)"
echo "$output" | grep "Memory total/used/free+share/buff/cache:"
)
end_test