Skip to content

Commit 33edaf3

Browse files
xentecalexmv
authored andcommitted
Consolidate backup timestamp expressions
1 parent 576a71e commit 33edaf3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

entrypoint.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,17 +477,19 @@ appManagePy() {
477477
}
478478
appBackup() {
479479
echo "Starting backup process ..."
480-
if [ -d "/tmp/backup-$(date "+%D-%H-%M-%S")" ]; then
481-
echo "Temporary backup folder for \"$(date "+%D-%H-%M-%S")\" already exists. Aborting."
480+
local TIMESTAMP
481+
TIMESTAMP=$(date "+%D-%H-%M-%S")
482+
if [ -d "/tmp/backup-$TIMESTAMP" ]; then
483+
echo "Temporary backup folder for \"$TIMESTAMP\" already exists. Aborting."
482484
echo "Backup process failed. Exiting."
483485
exit 1
484486
fi
485487
local BACKUP_FOLDER
486-
BACKUP_FOLDER="/tmp/backup-$(date "+%D-%H-%M-%S")"
488+
BACKUP_FOLDER="/tmp/backup-$TIMESTAMP)"
487489
mkdir -p "$BACKUP_FOLDER"
488490
waitingForDatabase
489491
pg_dump -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" "$DB_NAME" > "$BACKUP_FOLDER/database-postgres.sql"
490-
tar -zcvf "$DATA_DIR/backups/backup-$(date "+%D-%H-%M-%S").tar.gz" "$BACKUP_FOLDER/"
492+
tar -zcvf "$DATA_DIR/backups/backup-$TIMESTAMP.tar.gz" "$BACKUP_FOLDER/"
491493
rm -r "${BACKUP_FOLDER:?}/"
492494
echo "Backup process succeeded."
493495
exit 0

0 commit comments

Comments
 (0)