Skip to content

Commit 4799a2f

Browse files
committed
Fix shellcheck complaints
1 parent cf988bf commit 4799a2f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

internal/pgbackrest/config.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,14 @@ func DedicatedSnapshotVolumeRestoreCommand(pgdata string, tablespaceVolumes []*c
287287
// Otherwise return 1, Job will fail, and we will not proceed with snapshot.
288288
restoreScript := `declare -r pgdata="$1" opts="$2"
289289
BACKUP_LABEL="xxx"
290-
if [ -e "` + pgdata + `/backup_label" ]
290+
if [[ -e "` + pgdata + `/backup_label" ]]
291291
then
292-
BACKUP_LABEL=$(md5sum ` + pgdata + `/backup_label | awk '{print $1}')
292+
if BACKUP_LABEL=$(md5sum ` + pgdata + `/backup_label); then
293+
BACKUP_LABEL=$(echo "${BACKUP_LABEL}" | awk '{print $1}')
294+
else
295+
echo "Error getting checksum of backup_label."
296+
exit 1
297+
fi
293298
fi
294299
echo "Starting pgBackRest delta restore"
295300
@@ -299,11 +304,16 @@ bash -xc "pgbackrest restore ${opts}"
299304
rm -f "${pgdata}/patroni.dynamic.json"
300305
301306
BACKUP_LABEL_POST="xxx"
302-
if [ -e "` + pgdata + `/backup_label" ]
307+
if [[ -e "` + pgdata + `/backup_label" ]]
303308
then
304-
BACKUP_LABEL_POST=$(md5sum ` + pgdata + `/backup_label | awk '{print $1}')
309+
if BACKUP_LABEL_POST=$(md5sum ` + pgdata + `/backup_label); then
310+
BACKUP_LABEL_POST=$(echo "${BACKUP_LABEL_POST}" | awk '{print $1}')
311+
else
312+
echo "Error getting checksum of backup_label."
313+
exit 1
314+
fi
305315
fi
306-
if [ "$BACKUP_LABEL" != "$BACKUP_LABEL_POST" ]
316+
if [[ "${BACKUP_LABEL}" != "${BACKUP_LABEL_POST}" ]]
307317
then
308318
exit 0
309319
fi

0 commit comments

Comments
 (0)