@@ -144,58 +144,63 @@ if [ -z "$supported" ]; then
144
144
exit 1
145
145
fi
146
146
147
- # Bring in the requirements file
148
- min_rsync=" "
149
- min_openssh=" "
150
- min_jq=" "
151
- # shellcheck source=share/github-backup-utils/requirements.txt
152
- . " $( dirname " ${BASH_SOURCE[0]} " ) /../share/github-backup-utils/requirements.txt"
153
-
154
- # source disk size file
155
- # shellcheck source=share/github-backup-utils/ghe-rsync-size.sh
156
- . " $( dirname " ${BASH_SOURCE[0]} " ) /../share/github-backup-utils/ghe-rsync-size.sh"
157
-
158
- # Display dir requirements for repositories and mysql
159
- available_space=$( df -B 1k $GHE_DATA_DIR | awk ' END{printf "%.0f", $4 * 1024}' )
160
- echo " Available space: $available_space " 1>&2
161
-
162
- repos_disk_size=$( transfer_size repositories /tmp)
163
- pages_disk_size=$( transfer_size pages /tmp)
164
- es_disk_size=$( transfer_size elasticsearch /tmp)
165
- stor_disk_size=$( transfer_size storage /tmp)
166
- minio_disk_size=$( transfer_size minio /tmp)
167
- mysql_disk_size=$( transfer_size mysql /tmp)
168
-
169
- min_disk_req=$(( $(echo "$repos_disk_size " | awk '{printf "% .0 f", $1 }') + $(echo "$pages_disk_size " | awk '{printf "% .0 f", $1 }') + $(echo "$es_disk_size " | awk '{printf "% .0 f", $1 }') + $(echo "$stor_disk_size " | awk '{printf "% .0 f", $1 }') + $(echo "$minio_disk_size " | awk '{printf "% .0 f", $1 }') + $(echo "$mysql_disk_size " | awk '{printf "% .0 f", $1 / 2 }') ))
170
- echo " repositories = $repos_disk_size , pages: $pages_disk_size , elasticsearch: $es_disk_size , storage: $stor_disk_size , minio: $minio_disk_size , mysql: $mysql_disk_size " 1>&2
171
- echo " min_disk_required for backup = $min_disk_req bytes" 1>&2
172
-
173
- if [[ $available_space -lt $min_disk_req ]]; then
174
- echo " There is not enough disk space for the backup. Please allocate more space and continue." 1>&2
175
- exit 1
176
- fi
147
+ if [[ " $CALLING_SCRIPT " == " ghe-backup" ]]; then
148
+ # Bring in the requirements file
149
+ min_rsync=" "
150
+ min_openssh=" "
151
+ min_jq=" "
152
+ # shellcheck source=share/github-backup-utils/requirements.txt
153
+ . " $( dirname " ${BASH_SOURCE[0]} " ) /../share/github-backup-utils/requirements.txt"
154
+
155
+ # source disk size file
156
+ # shellcheck source=share/github-backup-utils/ghe-rsync-size.sh
157
+ . " $( dirname " ${BASH_SOURCE[0]} " ) /../share/github-backup-utils/ghe-rsync-size.sh"
158
+
159
+ # Display dir requirements for repositories and mysql
160
+ echo " Checking host for sufficient space for a backup..." 1>&2
161
+ available_space=$( df -B 1k $GHE_DATA_DIR | awk ' END{printf "%.0f", $4 * 1024}' )
162
+ printf " Available space: %d MB. We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time.\n" " $(( available_space / 1024 ** 2 )) " 1>&2
163
+
164
+ repos_disk_size=$( transfer_size repositories /tmp)
165
+ pages_disk_size=$( transfer_size pages /tmp)
166
+ es_disk_size=$( transfer_size elasticsearch /tmp)
167
+ stor_disk_size=$( transfer_size storage /tmp)
168
+ minio_disk_size=$( transfer_size minio /tmp)
169
+ mysql_disk_size=$( transfer_size mysql /tmp)
170
+ actions_disk_size=$( transfer_size actions /tmp)
171
+ mssql_disk_size=$( transfer_size mssql /tmp)
172
+
173
+ min_disk_req=$(( $(echo "$repos_disk_size " | awk '{printf "% .0 f", $1 }') + $(echo "$pages_disk_size " | awk '{printf "% .0 f", $1 }') + $(echo "$es_disk_size " | awk '{printf "% .0 f", $1 }') + $(echo "$stor_disk_size " | awk '{printf "% .0 f", $1 }') + $(echo "$minio_disk_size " | awk '{printf "% .0 f", $1 }') + $(echo "$mysql_disk_size " | awk '{printf "% .0 f", $1 / 2 }') + $(echo "$actions_disk_size " | awk '{printf "% .0 f", $1 }') + $(echo "$mssql_disk_size " | awk '{printf "% .0 f", $1 }') ))
174
+ echo " Data transfer size for - repositories = $repos_disk_size , pages: $pages_disk_size , elasticsearch: $es_disk_size , storage: $stor_disk_size , minio: $minio_disk_size , mysql: $mysql_disk_size , actions: $actions_disk_size , mssql: $mssql_disk_size " 1>&2
175
+ printf " min_disk_required for this backup is at least %d MB\n" " $(( min_disk_req / 1024 ** 2 )) " 1>&2
176
+
177
+ if [[ $available_space -lt $min_disk_req ]]; then
178
+ echo " There is not enough disk space for the backup. Please allocate more space and continue." 1>&2
179
+ exit 1
180
+ fi
177
181
178
- # Check rsync, openssh & jq versions
179
- rsync_version=$( rsync --version | grep ' version' | awk ' {print $3}' )
180
- if awk " BEGIN {exit !($rsync_version < $min_rsync )}" & > /dev/null; then
181
- echo " rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2
182
- echo " Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2
183
- exit 1
184
- fi
182
+ # Check rsync, openssh & jq versions
183
+ rsync_version=$( rsync --version | grep ' version' | awk ' {print $3}' )
184
+ if awk " BEGIN {exit !($rsync_version < $min_rsync )}" & > /dev/null; then
185
+ echo " rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2
186
+ echo " Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2
187
+ exit 1
188
+ fi
185
189
186
- ssh_version=$( ssh -V 2>&1 | awk ' {print $1}' | grep -oPm 1 ' [\d\.]+' | head -1)
187
- if awk " BEGIN {exit !($ssh_version < $min_openssh )}" & > /dev/null; then
188
- echo " openSSH version $ssh_version in backup-host does not meet minimum requirements." 1>&2
189
- echo " Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2
190
- exit 1
191
- fi
190
+ ssh_version=$( ssh -V 2>&1 | awk ' {print $1}' | grep -oPm 1 ' [\d\.]+' | head -1)
191
+ if awk " BEGIN {exit !($ssh_version < $min_openssh )}" & > /dev/null; then
192
+ echo " openSSH version $ssh_version in backup-host does not meet minimum requirements." 1>&2
193
+ echo " Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2
194
+ exit 1
195
+ fi
192
196
193
- jq_version=$( jq --version | awk -F\- ' {print $2}' )
194
- if awk " BEGIN {exit !($jq_version < $min_jq )}" & > /dev/null; then
195
- echo " jq version $jq_version in backup-host does not meet minimum requirements." 1>&2
196
- echo " Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2
197
- exit 1
197
+ jq_version=$( jq --version | awk -F\- ' {print $2}' )
198
+ if awk " BEGIN {exit !($jq_version < $min_jq )}" & > /dev/null; then
199
+ echo " jq version $jq_version in backup-host does not meet minimum requirements." 1>&2
200
+ echo " Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2
201
+ exit 1
202
+ fi
203
+ echo " Backup host meets minimum software requirements for OpenSSH, rsync and jq." 1>&2
198
204
fi
199
205
200
-
201
206
echo " Connect $hostname :$port OK (v$version )"
0 commit comments