fix: redirect logs to stderr and reduce size thresholds in backup/verify scripts
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m42s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m42s
This commit is contained in:
@@ -77,10 +77,10 @@ YELLOW='\033[1;33m'
|
|||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
LOG_PREFIX="[Backup ${TIMESTAMP}]"
|
LOG_PREFIX="[Backup ${TIMESTAMP}]"
|
||||||
|
|
||||||
log() { echo "${LOG_PREFIX} $1"; }
|
log() { echo "${LOG_PREFIX} $1" >&2; }
|
||||||
log_success() { echo -e "${LOG_PREFIX} ${GREEN}✅ $1${NC}"; }
|
log_success() { echo -e "${LOG_PREFIX} ${GREEN}✅ $1${NC}" >&2; }
|
||||||
log_error() { echo -e "${LOG_PREFIX} ${RED}❌ ERROR: $1${NC}"; }
|
log_error() { echo -e "${LOG_PREFIX} ${RED}❌ ERROR: $1${NC}" >&2; }
|
||||||
log_warning() { echo -e "${LOG_PREFIX} ${YELLOW}⚠️ $1${NC}"; }
|
log_warning() { echo -e "${LOG_PREFIX} ${YELLOW}⚠️ $1${NC}" >&2; }
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# TELEGRAM
|
# TELEGRAM
|
||||||
@@ -161,7 +161,7 @@ Date : $(date '+%Y-%m-%d %H:%M:%S')"
|
|||||||
# Vérification taille
|
# Vérification taille
|
||||||
local size_bytes
|
local size_bytes
|
||||||
size_bytes=$(stat -c %s "${dump_file}" 2>/dev/null || stat -f %z "${dump_file}")
|
size_bytes=$(stat -c %s "${dump_file}" 2>/dev/null || stat -f %z "${dump_file}")
|
||||||
local min_bytes=$((1024 * 1024)) # 1MB minimum
|
local min_bytes=1024 # 1KB minimum (safe for new/small databases)
|
||||||
|
|
||||||
if [ "${size_bytes}" -lt "${min_bytes}" ]; then
|
if [ "${size_bytes}" -lt "${min_bytes}" ]; then
|
||||||
log_error "Dump trop petit ($(numfmt --to=iec ${size_bytes})) — base de données vide ?"
|
log_error "Dump trop petit ($(numfmt --to=iec ${size_bytes})) — base de données vide ?"
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ GREEN='\033[0;32m'
|
|||||||
YELLOW='\033[1;33m'
|
YELLOW='\033[1;33m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
log() { echo "[Verify ${TIMESTAMP}] $1"; }
|
log() { echo "[Verify ${TIMESTAMP}] $1" >&2; }
|
||||||
log_success() { echo -e "[Verify ${TIMESTAMP}] ${GREEN}✅ $1${NC}"; }
|
log_success() { echo -e "[Verify ${TIMESTAMP}] ${GREEN}✅ $1${NC}" >&2; }
|
||||||
log_warning() { echo -e "[Verify ${TIMESTAMP}] ${YELLOW}⚠️ WARNING: $1${NC}"; }
|
log_warning() { echo -e "[Verify ${TIMESTAMP}] ${YELLOW}⚠️ WARNING: $1${NC}" >&2; }
|
||||||
log_error() { echo -e "[Verify ${TIMESTAMP}] ${RED}❌ ERROR: $1${NC}"; }
|
log_error() { echo -e "[Verify ${TIMESTAMP}] ${RED}❌ ERROR: $1${NC}" >&2; }
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# 1. LOAD CONFIGURATION
|
# 1. LOAD CONFIGURATION
|
||||||
@@ -59,7 +59,7 @@ APP_HEALTH_URL="${APP_HEALTH_URL:-http://localhost:8001/health}"
|
|||||||
|
|
||||||
# Thresholds
|
# Thresholds
|
||||||
MAX_SNAPSHOT_AGE_HOURS=8
|
MAX_SNAPSHOT_AGE_HOURS=8
|
||||||
MIN_SNAPSHOT_SIZE_MB=1
|
MIN_SNAPSHOT_SIZE_KB=10 # 10KB minimum (safe for new/small databases)
|
||||||
MAX_DISK_USAGE_PERCENT=85
|
MAX_DISK_USAGE_PERCENT=85
|
||||||
|
|
||||||
# Telegram
|
# Telegram
|
||||||
@@ -136,7 +136,7 @@ check_recent_snapshot() {
|
|||||||
|
|
||||||
check_snapshot_size() {
|
check_snapshot_size() {
|
||||||
local snapshot_path="$1"
|
local snapshot_path="$1"
|
||||||
log "Check 2/8: Snapshot size > ${MIN_SNAPSHOT_SIZE_MB}MB..."
|
log "Check 2/8: Snapshot size > ${MIN_SNAPSHOT_SIZE_KB}KB..."
|
||||||
|
|
||||||
if [ -z "${snapshot_path}" ] || [ ! -f "${snapshot_path}" ]; then
|
if [ -z "${snapshot_path}" ] || [ ! -f "${snapshot_path}" ]; then
|
||||||
log_warning "No snapshot to size-check."
|
log_warning "No snapshot to size-check."
|
||||||
@@ -145,10 +145,10 @@ check_snapshot_size() {
|
|||||||
|
|
||||||
local size_bytes
|
local size_bytes
|
||||||
size_bytes=$(stat -c %s "${snapshot_path}" 2>/dev/null || stat -f %z "${snapshot_path}" 2>/dev/null)
|
size_bytes=$(stat -c %s "${snapshot_path}" 2>/dev/null || stat -f %z "${snapshot_path}" 2>/dev/null)
|
||||||
local min_bytes=$((MIN_SNAPSHOT_SIZE_MB * 1024 * 1024))
|
local min_bytes=$((MIN_SNAPSHOT_SIZE_KB * 1024))
|
||||||
|
|
||||||
if [ "${size_bytes}" -lt "${min_bytes}" ]; then
|
if [ "${size_bytes}" -lt "${min_bytes}" ]; then
|
||||||
log_error "Snapshot size is $(numfmt --to=iec ${size_bytes}) which is below minimum ${MIN_SNAPSHOT_SIZE_MB}MB — likely empty dump!"
|
log_error "Snapshot size is $(numfmt --to=iec ${size_bytes}) which is below minimum ${MIN_SNAPSHOT_SIZE_KB}KB — likely empty dump!"
|
||||||
FAILURES=$((FAILURES + 1))
|
FAILURES=$((FAILURES + 1))
|
||||||
else
|
else
|
||||||
log_success "Snapshot size: $(numfmt --to=iec ${size_bytes})"
|
log_success "Snapshot size: $(numfmt --to=iec ${size_bytes})"
|
||||||
|
|||||||
Reference in New Issue
Block a user