Skip to content

Commit 8aaccc3

Browse files
authored
Merge pull request #283 from github/upd-backup-size-units
Update Backup transfer_size units displayed in MB
2 parents e18a31e + 853ec7c commit 8aaccc3

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

bin/ghe-backup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ fi
284284
log_info "Checking for leaked ssh keys ..."
285285
ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true
286286

287-
log_info "Restore of $GHE_HOSTNAME finished."
287+
log_info "Backup of $GHE_HOSTNAME finished."
288288

289289
# Remove in-progress file
290290
ghe_backup_finished

bin/ghe-host-check

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then
159159
#Display dir requirements for repositories and mysql
160160
echo "Checking host for sufficient space for a backup..." 1>&2
161161
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
162+
echo "We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." 1>&2
163163

164164
repos_disk_size=$(transfer_size repositories /tmp)
165165
pages_disk_size=$(transfer_size pages /tmp)
@@ -170,17 +170,29 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then
170170
actions_disk_size=$(transfer_size actions /tmp)
171171
mssql_disk_size=$(transfer_size mssql /tmp)
172172

173-
#min_disk_req=$(( $(echo "$repos_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$pages_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$es_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$stor_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$minio_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mysql_disk_size" | awk '{printf "%.0f", $1/2}') + $(echo "$actions_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mssql_disk_size" | awk '{printf "%.0f", $1}') ))
174-
min_disk_req=$(( $(echo "$repos_disk_size") + $(echo "$pages_disk_size") + $(echo "$es_disk_size") + $(echo "$stor_disk_size") + $(echo "$minio_disk_size") + $(echo "$mysql_disk_size") + $(echo "$actions_disk_size") + $(echo "$mssql_disk_size") ))
175-
echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size \npages: $pages_disk_size \nelasticsearch: $es_disk_size \nstorage: $stor_disk_size \nminio: $minio_disk_size \nmysql: $mysql_disk_size \nactions: $actions_disk_size \nmssql: $mssql_disk_size" 1>&2
176-
printf "min_disk_required for this backup is at least %d MB\n" "$((min_disk_req / 1024 ** 2))" 1>&2
173+
min_disk_req=$((repos_disk_size + pages_disk_size + es_disk_size + stor_disk_size + minio_disk_size + mysql_disk_size + actions_disk_size + mssql_disk_size))
174+
echo "Available space: $((available_space / (1024 ** 2))) MB" 1>&2
175+
echo -e "Min Disk required for this backup is at least $min_disk_req MB\n" 1>&2
176+
177+
cat <<DATA_TRANSFER_SIZE 1>&2
178+
### Data Transfer Sizes
179+
repositories: $repos_disk_size MB
180+
pages: $pages_disk_size MB
181+
elasticsearch: $es_disk_size MB
182+
storage: $stor_disk_size MB
183+
minio: $minio_disk_size MB
184+
mysql: $mysql_disk_size MB
185+
actions: $actions_disk_size MB
186+
mssql: $mssql_disk_size MB
187+
DATA_TRANSFER_SIZE
177188

178189
if [[ $available_space -lt $min_disk_req ]]; then
179190
echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2
180191
exit 1
181192
fi
182193

183194
#Check rsync, openssh & jq versions
195+
echo "### Software versions" 1>&2
184196
rsync_version=$(rsync --version | grep 'version' | awk '{print $3}')
185197
if awk "BEGIN {exit !($rsync_version < $min_rsync)}" &> /dev/null; then
186198
echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ transfer_size()
6161
total_file_size=$(ghe-rsync -arn --stats \
6262
-e "ssh -q $GHE_EXTRA_SSH_OPTS -p 122 -l admin" \
6363
--rsync-path="sudo -u $user rsync" \
64-
$link_dest/$1 \
64+
"$link_dest"/"$1" \
6565
--ignore-missing-args \
6666
"$GHE_HOSTNAME:$data_user_dir/" \
6767
"$dest_dir/" | grep "Total transferred file size" | sed 's/.*size: //; s/,//g')
6868

6969
# Reduce mysql size as only the compressed file is transferred
7070
if [[ "$1" == "mysql" ]]; then
71-
echo "$total_file_size" | awk '{printf "%.0f\n", $1/2}'
71+
echo "$total_file_size" | awk '{if ($1 > 0) printf "%.0f\n", int(($1+999999.5)/2000000); else printf "0\n"}'
7272
else
73-
echo "$total_file_size" | awk '{printf "%.0f\n", $1}'
73+
echo "$total_file_size" | awk '{if ($1 > 0) printf "%.0f\n", int(($1+999999.5)/1000000); else printf "0\n"}'
7474
fi
7575
}

0 commit comments

Comments
 (0)