chore: sync repository to current working state
Some checks failed
Build and Test / Build Server (Linux) (push) Has been cancelled
Build and Test / Build Agent (Windows) (push) Has been cancelled
Build and Test / Security Audit (push) Has been cancelled
Build and Test / Build Summary (push) Has been cancelled
Run Tests / Test Server (push) Has been cancelled
Run Tests / Test Agent (push) Has been cancelled
Run Tests / Code Coverage (push) Has been cancelled
Run Tests / Lint and Format Check (push) Has been cancelled
Some checks failed
Build and Test / Build Server (Linux) (push) Has been cancelled
Build and Test / Build Agent (Windows) (push) Has been cancelled
Build and Test / Security Audit (push) Has been cancelled
Build and Test / Build Summary (push) Has been cancelled
Run Tests / Test Server (push) Has been cancelled
Run Tests / Test Agent (push) Has been cancelled
Run Tests / Code Coverage (push) Has been cancelled
Run Tests / Lint and Format Check (push) Has been cancelled
Brings azcomputerguru/guru-connect up to the authoritative working copy that had been maintained in the claudetools monorepo: Phase 1 security and infrastructure (middleware, metrics, utils, token blacklist, deployment scripts, security audits) plus the native-remote-control integration spec. Preserves the repo .gitignore, .cargo, and server/static/downloads. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
80
server/backup-postgres.sh
Normal file
80
server/backup-postgres.sh
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
# GuruConnect PostgreSQL Backup Script
|
||||
# Creates a compressed backup of the GuruConnect database
|
||||
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
DB_NAME="guruconnect"
|
||||
DB_USER="guruconnect"
|
||||
DB_HOST="localhost"
|
||||
BACKUP_DIR="/home/guru/backups/guruconnect"
|
||||
DATE=$(date +%Y-%m-%d-%H%M%S)
|
||||
BACKUP_FILE="$BACKUP_DIR/guruconnect-$DATE.sql.gz"
|
||||
|
||||
# Retention policy (days)
|
||||
DAILY_RETENTION=30
|
||||
WEEKLY_RETENTION=28 # 4 weeks
|
||||
MONTHLY_RETENTION=180 # 6 months
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo "========================================="
|
||||
echo "GuruConnect Database Backup"
|
||||
echo "========================================="
|
||||
echo "Date: $(date)"
|
||||
echo "Database: $DB_NAME"
|
||||
echo "Backup file: $BACKUP_FILE"
|
||||
echo ""
|
||||
|
||||
# Create backup directory if it doesn't exist
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
# Perform backup
|
||||
echo "Starting backup..."
|
||||
if PGPASSWORD="${DB_PASSWORD:-}" pg_dump -h "$DB_HOST" -U "$DB_USER" "$DB_NAME" | gzip > "$BACKUP_FILE"; then
|
||||
BACKUP_SIZE=$(du -h "$BACKUP_FILE" | cut -f1)
|
||||
echo -e "${GREEN}SUCCESS: Backup completed${NC}"
|
||||
echo "Backup size: $BACKUP_SIZE"
|
||||
else
|
||||
echo -e "${RED}ERROR: Backup failed${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Retention policy enforcement
|
||||
echo ""
|
||||
echo "Applying retention policy..."
|
||||
|
||||
# Keep daily backups for 30 days
|
||||
find "$BACKUP_DIR" -name "guruconnect-*.sql.gz" -type f -mtime +$DAILY_RETENTION -delete
|
||||
DAILY_DELETED=$?
|
||||
|
||||
# Keep weekly backups (Sunday) for 4 weeks
|
||||
# For weekly backups, we keep only files created on Sunday that are older than 30 days but younger than 58 days
|
||||
# Note: This is a simplified approach - production might use more sophisticated logic
|
||||
|
||||
# Keep monthly backups (1st of month) for 6 months
|
||||
# Similar simplified approach
|
||||
|
||||
echo -e "${GREEN}Retention policy applied${NC}"
|
||||
echo ""
|
||||
|
||||
# Summary
|
||||
echo "========================================="
|
||||
echo "Backup Summary"
|
||||
echo "========================================="
|
||||
echo "Backup file: $BACKUP_FILE"
|
||||
echo "Backup size: $BACKUP_SIZE"
|
||||
echo "Backups in directory: $(ls -1 $BACKUP_DIR/*.sql.gz 2>/dev/null | wc -l)"
|
||||
echo ""
|
||||
|
||||
# Display disk usage
|
||||
echo "Backup directory disk usage:"
|
||||
du -sh "$BACKUP_DIR"
|
||||
echo ""
|
||||
|
||||
echo -e "${GREEN}Backup completed successfully!${NC}"
|
||||
Reference in New Issue
Block a user