Skip to content

Commit 80e0af3

Browse files
committed
simplify cluster output & parsing
1 parent 077a10e commit 80e0af3

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

share/github-backup-utils/ghe-rsync-size

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,20 @@ transfer_size()
6060
esac
6161

6262
# Check if instance is cluster and fetch appropriate primary host for the different components
63-
ghe-ssh "$host" "[ -f /etc/github/cluster ]"
64-
cluster_status=$?
65-
66-
if [[ $cluster_status -eq 0 ]]; then
67-
cluster_conf_out=$(ghe-ssh "$host" "cat /data/user/common/cluster.conf")
63+
if "$CLUSTER"; then
6864
cluster_nodes_output=$(ghe-ssh "$host" "ghe-cluster-nodes -i")
6965
case $1 in
70-
elasticsearch | storage | pages)
71-
cluster_host=$(echo "$cluster_conf_out" | awk -v srv="$backup_data-server = true" '/cluster/ { prevA = $0 } $0 ~ srv { print prevA }' | head -1 | awk -F '"' '{print $2}')
66+
elasticsearch | storage | pages | actions | mssql)
67+
cluster_host=$(ghe-ssh "$host" "ghe-cluster-nodes -r $backup_data" | head -1)
7268
;;
7369
mysql)
7470
cluster_host=$(ghe-ssh "$host" "ghe-config cluster.mysql-master")
7571
;;
7672
repositories)
77-
cluster_host=$(echo "$cluster_conf_out" | awk '/git-server = true/ { print prevA } /cluster/ { prevA = $0 }' | head -1 | awk -F '"' '{print $2}')
73+
cluster_host=$(ghe-ssh "$host" "ghe-cluster-nodes -r git" | head -1)
7874
;;
7975
*)
80-
echo "Unknown backup data: $1"
81-
exit 1
76+
exit 0
8277
;;
8378
esac
8479
host=$(echo "$cluster_nodes_output" | grep "$cluster_host" | awk '{print $2}' | head -1)

0 commit comments

Comments
 (0)