Skip to content

Commit 2c661db

Browse files
committed
Styling fixups
Expanded short flags into long flags whenever possible, and double-quoted bare variable interpolations. Also added a comment about why one of the variables in ghe-backup-minio needs to stay unquoted.
1 parent 20d7f00 commit 2c661db

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

share/github-backup-utils/ghe-backup-minio

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ set -e
1010
# shellcheck source=share/github-backup-utils/ghe-backup-config
1111
. "$(dirname "${BASH_SOURCE[0]}")/ghe-backup-config"
1212

13-
bm_start "$(basename $0)"
13+
bm_start "$(basename "${0}")"
1414

1515
# Set up remote host and root backup snapshot directory based on config
16-
port=$(ssh_port_part "$GHE_HOSTNAME")
17-
host=$(ssh_host_part "$GHE_HOSTNAME")
18-
backup_dir="$GHE_SNAPSHOT_DIR/minio"
16+
port="$(ssh_port_part "${GHE_HOSTNAME}")"
17+
host="$(ssh_host_part "${GHE_HOSTNAME}")"
18+
backup_dir="${GHE_SNAPSHOT_DIR}/minio"
1919

2020
# Verify rsync is available.
2121
if ! command -v rsync 1> /dev/null 2>&1; then
@@ -24,26 +24,33 @@ if ! command -v rsync 1> /dev/null 2>&1; then
2424
fi
2525

2626
# Perform a host-check and establish GHE_REMOTE_XXX variables.
27-
ghe_remote_version_required "$host"
27+
ghe_remote_version_required "${host}"
2828

2929
# Make sure root backup dir exists if this is the first run
30-
mkdir -p "$backup_dir"
30+
mkdir -p "${backup_dir}"
3131

3232
# If we have a previous increment and it is not empty, avoid transferring existing files via rsync's
3333
# --link-dest support. This also decreases physical space usage considerably.
34-
if [ -d "$GHE_DATA_DIR/current/minio" ] && [ "$(ls -A $GHE_DATA_DIR/current/minio)" ]; then
35-
link_dest="--link-dest=$GHE_DATA_DIR/current/minio"
34+
# Hilariously, this HAS to stay unquoted when you call `rsync` further
35+
# down because when the shell interpolates this out, `rsync` will throw
36+
# an absolute fit if this variable is quoted. Surprise!
37+
if [[ -d "${GHE_DATA_DIR}/current/minio" ]] &&
38+
[[ "$(ls -A "${GHE_DATA_DIR}/current/minio")" ]]; then
39+
link_dest="--link-dest=${GHE_DATA_DIR}/current/minio"
3640
fi
3741

3842
# Transfer all minio data from the user data directory using rsync.
39-
ghe_verbose "* Transferring minio files from $host ..."
43+
ghe_verbose "* Transferring minio files from ${host} ..."
4044

41-
ghe-rsync -avz \
42-
-e "ghe-ssh -p $port" \
45+
ghe-rsync \
46+
--archive \
47+
--verbose \
48+
--compress \
49+
--rsh="ghe-ssh -p ${port}" \
4350
--rsync-path='sudo -u minio rsync' \
44-
--exclude ".minio.sys" \
45-
$link_dest \
46-
"$host:$GHE_REMOTE_DATA_USER_DIR/minio/" \
47-
"$GHE_SNAPSHOT_DIR/minio" 1>&3
51+
--exclude=".minio.sys" \
52+
${link_dest} \
53+
"${host}:${GHE_REMOTE_DATA_USER_DIR}/minio/" \
54+
"${GHE_SNAPSHOT_DIR}/minio" 1>&3
4855

49-
bm_end "$(basename $0)"
56+
bm_end "$(basename "${0}")"

0 commit comments

Comments
 (0)