From d1d11c46680ce1316231f0fc568728b60e203418 Mon Sep 17 00:00:00 2001 From: skobkin Date: Wed, 6 Nov 2024 17:55:49 +0000 Subject: [PATCH] Use .env file for backup configuration --- postgresql_backup/pg_backup.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/postgresql_backup/pg_backup.sh b/postgresql_backup/pg_backup.sh index e77646c..2c55f29 100644 --- a/postgresql_backup/pg_backup.sh +++ b/postgresql_backup/pg_backup.sh @@ -1,14 +1,15 @@ #!/bin/bash -# Configuration -HOST="localhost" -PORT="5432" -USER="your_postgres_user" -BACKUP_PATH="/path/to/backup/directory" -DUMP_FORMAT="custom" # Set to "custom" for .dump or "sql" for plaintext SQL -EXTENSION="dump" # Default extension +# Load environment variables from .env file +if [ -f .env ]; then + export $(grep -v '^#' .env | xargs) +else + echo ".env file not found! Please create it with the necessary configuration." + exit 1 +fi -# Adjust file extension based on dump format +# Set file extension based on DUMP_FORMAT +EXTENSION="dump" # Default extension for custom format if [[ "$DUMP_FORMAT" == "sql" ]]; then EXTENSION="sql.gz" fi