Skip to content

Commit 0b6670b

Browse files
djdefihubot
authored andcommitted
Merge pull request #312 from github/djdefi-host-info
Capture backup host info in backup output
1 parent 8683e1c commit 0b6670b

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

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

test/test-ghe-backup.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,3 +649,16 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older"
649649
done
650650
)
651651
end_test
652+
653+
# Check that information on system where backup-utils is installed is collected
654+
begin_test "ghe-backup collects information on system where backup-utils is installed"
655+
(
656+
set -e
657+
658+
output=$(ghe-backup)
659+
echo "$output" | grep "Running on: $(cat /etc/issue.net)"
660+
echo "$output" | grep "CPUs: $(nproc)"
661+
echo "$output" | grep "Memory total/used/free+share/buff/cache:"
662+
663+
)
664+
end_test

0 commit comments

Comments
 (0)