Skip to content

Commit af47b86

Browse files
authored
Merge pull request #413 from github/enterprise-3.8-backport-312-djdefi-host-info
Backport 312 for 3.8: Capture backup host info in backup output
2 parents e97fd11 + 6a37aac commit af47b86

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

bin/ghe-backup

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,30 @@ if [ -n "$GHE_ALLOW_REPLICA_BACKUP" ]; then
154154
echo "Warning: backing up a high availability replica may result in inconsistent or unreliable backups."
155155
fi
156156

157+
# Output system information of the backup host
158+
159+
# If /etc/issue.net exists, use it to get the OS version
160+
if [ -f /etc/issue.net ]; then
161+
echo "Running on: $(cat /etc/issue.net)"
162+
else
163+
echo "Running on: Unknown OS"
164+
fi
165+
166+
# If nproc command exists, use it to get the number of CPUs
167+
if command -v nproc >/dev/null 2>&1; then
168+
echo "CPUs: $(nproc)"
169+
else
170+
echo "CPUs: Unknown"
171+
fi
172+
173+
# If the free command exists, use it to get the memory details
174+
if command -v free >/dev/null 2>&1; then
175+
echo "Memory $(free -m | grep '^Mem:' | awk '{print "total/used/free+share/buff/cache: " $2 "/" $3 "/" $4 "+" $5 "/" $6 "/" $7}')"
176+
else
177+
echo "Memory: Unknown"
178+
fi
179+
180+
157181
# Log backup start message in /var/log/syslog on remote instance
158182
ghe_remote_logger "Starting backup from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP ..."
159183

test/test-ghe-backup.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,3 +722,16 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older"
722722
done
723723
)
724724
end_test
725+
726+
# Check that information on system where backup-utils is installed is collected
727+
begin_test "ghe-backup collects information on system where backup-utils is installed"
728+
(
729+
set -e
730+
731+
output=$(ghe-backup)
732+
echo "$output" | grep "Running on: $(cat /etc/issue.net)"
733+
echo "$output" | grep "CPUs: $(nproc)"
734+
echo "$output" | grep "Memory total/used/free+share/buff/cache:"
735+
736+
)
737+
end_test

0 commit comments

Comments
 (0)