@@ -85,28 +85,33 @@ if [ $rc -ne 0 ]; then
85
85
exit $rc
86
86
fi
87
87
88
- CLUSTER=false
88
+ if [ -z " $CLUSTER " ]; then
89
+ CLUSTER=false
90
+ fi
89
91
if ghe-ssh " $host " -- \
90
92
" [ -f '$GHE_REMOTE_ROOT_DIR /etc/github/cluster' ]" ; then
91
93
CLUSTER=true
92
94
fi
93
95
96
+ set +e
94
97
# ensure all nodes in the cluster are online/reachable and running the same version
95
98
if " $CLUSTER " ; then
96
99
online_status=$( ghe-ssh " $host " ghe-cluster-host-check)
97
100
if [ " $online_status " != " Cluster is ready to configure." ]; then
98
- echo " Error: Not all nodes are online! Please ensure cluster is in a healthy state before using backup-utils." 1>&2
101
+ echo " $online_status " 1>&2
102
+ log_error " Error: Not all nodes are online! Please ensure cluster is in a healthy state before using backup-utils." 1>&2
99
103
exit 1
100
104
fi
101
105
102
106
node_version_list=$( ghe-ssh " $host " ghe-cluster-each -- ghe-version)
103
107
distinct_versions=$( echo " $node_version_list " | awk ' {split($0, a, ":"); print a[2]}' | awk ' {print $4}' | uniq | wc -l)
104
108
if [ " $distinct_versions " -ne 1 ]; then
105
109
echo " Version mismatch: $node_version_list " 1>&2
106
- echo " Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2
110
+ log_error " Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2
107
111
exit 1
108
112
fi
109
113
fi
114
+ set -e
110
115
111
116
version=$( echo " $output " | grep " GitHub Enterprise" | awk ' {print $NF}' )
112
117
@@ -115,6 +120,37 @@ if [ -z "$version" ]; then
115
120
exit 2
116
121
fi
117
122
123
+ NON_WRITABLE=" "
124
+ # ensure all nodes are writable
125
+ if [ " $CLUSTER " == " true" ] ; then
126
+ if [ -z " $GHE_FILE_SYSTEM_WRITE_CHECK " ]; then
127
+ if [ -d " /data/user/tmp" ]; then
128
+ WRITE_CHECK_FILE=" /data/user/tmp/test-ro-file.txt"
129
+ else
130
+ WRITE_CHECK_FILE=" /tmp/test-ro-file.txt"
131
+ fi
132
+ else
133
+ WRITE_CHECK_FILE=" $GHE_FILE_SYSTEM_CHECK /test-ro-file.txt"
134
+ fi
135
+
136
+ # Iterate through each node in the cluster
137
+ nodes=$( ghe-ssh " $host " ghe-cluster-nodes)
138
+ for node in $nodes ; do
139
+ if ! echo " set -o pipefail; ssh $node -- 'touch $WRITE_CHECK_FILE && rm $WRITE_CHECK_FILE '" | ghe-ssh " $host " /bin/bash; then
140
+ echo " File system is not writeable or no permission on $node " 1>&2
141
+ NON_WRITABLE+=" $node "
142
+ fi || true
143
+ done
144
+ # Display the comma-separated list of non-writable nodes
145
+ if [ -n " $NON_WRITABLE " ]; then
146
+ NON_WRITABLE=$( echo " $NON_WRITABLE " | sed ' s/ /, /g; s/, $//' )
147
+ log_error " Error: Following nodes are non-writable - $NON_WRITABLE . Please make sure the filesystem for all GHES nodes are writable." 1>&2
148
+ exit 1
149
+ else
150
+ log_info " All nodes are writable."
151
+ fi
152
+ fi
153
+
118
154
# Block restoring snapshots to older releases of GitHub Enterprise Server
119
155
if [ -n " $GHE_RESTORE_SNAPSHOT_PATH " ]; then
120
156
snapshot_version=$( cat $GHE_RESTORE_SNAPSHOT_PATH /version)
@@ -177,7 +213,7 @@ SKIP_MSG
177
213
178
214
# Display dir requirements for repositories and mysql
179
215
echo -e " \nChecking host for sufficient space for a backup..."
180
- available_space=$( df -B 1k $GHE_DATA_DIR | awk ' END{printf "%.0f", $4 * 1024}' )
216
+ available_space=$( df -B 1k $GHE_DATA_DIR | awk ' END{printf "%.0f", $4 * 1024}' )
181
217
echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time."
182
218
183
219
repos_disk_size=$( transfer_size repositories /tmp)
0 commit comments