chore(fixtures): enrichit les vaults de test (frontmatter complet, types fichiers pour vues/aper/us, dossiers avec accents+espaces, scripts dupliques, images/logs) + purge residus e2e-diagram
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
# PostgreSQL backup script for HabitForge
|
||||
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
BACKUP_DIR="/backups"
|
||||
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
||||
BACKUP_FILE="${BACKUP_DIR}/habitforge_backup_${TIMESTAMP}.sql.gz"
|
||||
RETENTION_DAYS=7
|
||||
|
||||
# Database settings (from environment)
|
||||
DB_HOST="${POSTGRES_HOST:-db}"
|
||||
DB_PORT="${POSTGRES_PORT:-5432}"
|
||||
DB_NAME="${POSTGRES_DB:-habitforge}"
|
||||
DB_USER="${POSTGRES_USER:-habitforge}"
|
||||
|
||||
# Create backup directory if it doesn't exist
|
||||
mkdir -p "${BACKUP_DIR}"
|
||||
|
||||
echo "Starting backup at $(date)"
|
||||
|
||||
# Perform backup
|
||||
PGPASSWORD="${POSTGRES_PASSWORD}" pg_dump \
|
||||
-h "${DB_HOST}" \
|
||||
-p "${DB_PORT}" \
|
||||
-U "${DB_USER}" \
|
||||
-d "${DB_NAME}" \
|
||||
--format=plain \
|
||||
--no-owner \
|
||||
--no-acl | gzip > "${BACKUP_FILE}"
|
||||
|
||||
# Check if backup was successful
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Backup completed successfully: ${BACKUP_FILE}"
|
||||
|
||||
# Get file size
|
||||
SIZE=$(du -h "${BACKUP_FILE}" | cut -f1)
|
||||
echo "Backup size: ${SIZE}"
|
||||
|
||||
# Remove old backups (older than RETENTION_DAYS)
|
||||
echo "Removing backups older than ${RETENTION_DAYS} days..."
|
||||
find "${BACKUP_DIR}" -name "habitforge_backup_*.sql.gz" -type f -mtime +${RETENTION_DAYS} -delete
|
||||
|
||||
# List remaining backups
|
||||
echo "Current backups:"
|
||||
ls -lh "${BACKUP_DIR}"/habitforge_backup_*.sql.gz 2>/dev/null || echo "No backups found"
|
||||
|
||||
else
|
||||
echo "Backup failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Backup finished at $(date)"
|
||||
Reference in New Issue
Block a user