mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 00:00:13 -08:00
Refactor variable assignments and improve script readability in validate-plex-backups.sh and validate-plex-recovery.sh
- Changed inline variable assignments to separate declaration and assignment for clarity. - Updated condition checks and log messages for better readability and consistency. - Added a backup of validate-plex-recovery.sh for safety. - Introduced a new script run-docker-tests.sh for testing setup in Docker containers. - Enhanced ssh-login.sh to improve condition checks and logging functionality.
This commit is contained in:
@@ -35,6 +35,7 @@ trap cleanup EXIT SIGINT SIGTERM
|
||||
ENV_FILE="$(dirname "$0")/../.env"
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
echo "Loading environment variables from $ENV_FILE"
|
||||
# shellcheck source=/dev/null
|
||||
source "$ENV_FILE"
|
||||
else
|
||||
echo "Error: .env file not found in $(dirname "$0")/.."
|
||||
@@ -133,7 +134,8 @@ send_notification() {
|
||||
local title="$1"
|
||||
local message="$2"
|
||||
local status="${3:-info}" # success, error, warning, info
|
||||
local hostname=$(hostname)
|
||||
local hostname
|
||||
hostname=$(hostname)
|
||||
|
||||
# Console notification
|
||||
log_message "$title: $message"
|
||||
@@ -157,7 +159,8 @@ send_notification() {
|
||||
# Function to upload to Backblaze B2
|
||||
upload_to_b2() {
|
||||
local file_path="$1"
|
||||
local filename=$(basename "$file_path")
|
||||
local filename
|
||||
filename=$(basename "$file_path")
|
||||
|
||||
# Check if B2 is configured
|
||||
if [ -z "$B2_APPLICATION_KEY_ID" ] || [ -z "$B2_APPLICATION_KEY" ] || [ -z "$B2_BUCKET_NAME" ]; then
|
||||
@@ -344,14 +347,11 @@ echo ""
|
||||
echo "=== PHASE 1: DATABASE BACKUP ==="
|
||||
log_message "Taking database backup using pg_dumpall as recommended by Immich documentation..."
|
||||
# Use pg_dumpall with recommended flags: --clean and --if-exists
|
||||
docker exec -t immich_postgres pg_dumpall \
|
||||
if ! docker exec -t immich_postgres pg_dumpall \
|
||||
--clean \
|
||||
--if-exists \
|
||||
--username="${DB_USERNAME}" \
|
||||
> "${DB_BACKUP_PATH}"
|
||||
|
||||
# Check if the dump was successful
|
||||
if [ $? -ne 0 ] || [ ! -s "${DB_BACKUP_PATH}" ]; then
|
||||
> "${DB_BACKUP_PATH}" || [ ! -s "${DB_BACKUP_PATH}" ]; then
|
||||
log_message "Error: Database backup failed or created an empty file."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user