- Created OPERATIONAL_RUNBOOK.md: comprehensive step-by-step procedures for both Docker and Standalone deployment modes covering deployment, daily ops, troubleshooting, backup/restore, disaster recovery, scaling, and updates - Created HEALTH_MONITORING_CHECKLIST.md: daily/weekly/monthly health check procedures with alert thresholds and quick troubleshooting reference - Created DISASTER_RECOVERY_PLAN.md: detailed procedures for 6 failure scenarios (database corruption, hardware failure, data center failure, app crash, disk full, network isolation) with RTO/RPO targets - Created CONFIGURATION_REFERENCE.md: complete documentation of all inventory.env parameters for both deployment modes with common scenarios and troubleshooting - Created EMERGENCY_PROCEDURES.md: quick-reference incident response playbook with 7 critical scenarios, decision tree, escalation path, and printable cheat sheet - Created scripts/backup.sh: automated backup script supporting both Docker and Standalone with integrity verification and retention management - Created scripts/restore.sh: restore script with triple confirmation, safety backups, and validation tests for both deployment modes - Created config/backup-cron.sh: installer for daily/weekly automated backup cron jobs (2 AM daily, 3 AM Sunday) All documentation covers dual-deployment modes with shared configuration files. Documentation is operator-ready with copy-paste commands and clear expected outputs.
36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
#!/bin/bash
|
|
# Phase 6, Plan 02, Task 3: Install Cron Jobs for Automated Backups
|
|
# Run with: sudo bash config/backup-cron.sh
|
|
|
|
DEPLOY_DIR=$(pwd)
|
|
CRON_SCHEDULE_DAILY="0 2 * * *" # 2 AM every day
|
|
CRON_SCHEDULE_WEEKLY="0 3 * * 0" # 3 AM every Sunday
|
|
|
|
# Check if running with sudo
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo "This script must be run with sudo"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Installing cron jobs for automated backups..."
|
|
|
|
# Create logs directory if it doesn't exist
|
|
mkdir -p "$DEPLOY_DIR/logs"
|
|
|
|
# Install daily backup
|
|
(crontab -l 2>/dev/null | grep -v "inventory backup" || echo ""; \
|
|
echo "$CRON_SCHEDULE_DAILY cd $DEPLOY_DIR && bash scripts/backup.sh daily >> logs/backup-daily.log 2>&1") | \
|
|
crontab -
|
|
|
|
# Install weekly backup
|
|
(crontab -l 2>/dev/null | grep -v "inventory backup" || echo ""; \
|
|
echo "$CRON_SCHEDULE_WEEKLY cd $DEPLOY_DIR && bash scripts/backup.sh weekly 90 >> logs/backup-weekly.log 2>&1") | \
|
|
crontab -
|
|
|
|
echo "✓ Cron jobs installed"
|
|
echo " Daily backup: $CRON_SCHEDULE_DAILY (retention: 30 days)"
|
|
echo " Weekly backup: $CRON_SCHEDULE_WEEKLY (retention: 90 days)"
|
|
echo ""
|
|
echo "View active cron jobs:"
|
|
crontab -l | grep backup
|