Skip to content

Commit 8ae8e24

Browse files
authored
Merge pull request #312 from github/djdefi-host-info
Capture backup host info in backup output
2 parents fd7d2c8 + 0b14b01 commit 8ae8e24

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
@@ -155,6 +155,30 @@ if [ -n "$GHE_ALLOW_REPLICA_BACKUP" ]; then
155155
echo "Warning: backing up a high availability replica may result in inconsistent or unreliable backups."
156156
fi
157157

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

test/test-ghe-backup.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,3 +734,16 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older"
734734
done
735735
)
736736
end_test
737+
738+
# Check that information on system where backup-utils is installed is collected
739+
begin_test "ghe-backup collects information on system where backup-utils is installed"
740+
(
741+
set -e
742+
743+
output=$(ghe-backup)
744+
echo "$output" | grep "Running on: $(cat /etc/issue.net)"
745+
echo "$output" | grep "CPUs: $(nproc)"
746+
echo "$output" | grep "Memory total/used/free+share/buff/cache:"
747+
748+
)
749+
end_test

0 commit comments

Comments
 (0)