Files
n8n-workflows/scripts/backup.sh
Sahiix@1 3c0a92c460 ssd (#10)
* ok

ok

* Refactor README for better structure and readability

Updated README to improve formatting and clarity.

* Initial plan

* Initial plan

* Initial plan

* Initial plan

* Comprehensive deployment infrastructure implementation

Co-authored-by: sahiixx <221578902+sahiixx@users.noreply.github.com>

* Add comprehensive deployment infrastructure - Docker, K8s, CI/CD, scripts

Co-authored-by: sahiixx <221578902+sahiixx@users.noreply.github.com>

* Add files via upload

* Complete deployment implementation - tested and working production deployment

Co-authored-by: sahiixx <221578902+sahiixx@users.noreply.github.com>

* Revert "Implement comprehensive deployment infrastructure for n8n-workflows documentation system"

* Update docker-compose.prod.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update scripts/health-check.sh

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: dopeuni444 <sahiixofficial@wgmail.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-09-29 09:31:37 +04:00

62 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# N8N Workflows Documentation - Backup Script
# Usage: ./scripts/backup.sh [backup-name]
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
BACKUP_NAME="${1:-$(date +%Y%m%d_%H%M%S)}"
BACKUP_DIR="$PROJECT_DIR/backups"
BACKUP_PATH="$BACKUP_DIR/backup_$BACKUP_NAME"
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
log() {
echo -e "${BLUE}[$(date '+%Y-%m-%d %H:%M:%S')]${NC} $1"
}
success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
# Create backup directory
mkdir -p "$BACKUP_PATH"
log "Creating backup: $BACKUP_NAME"
# Backup database
if [[ -f "$PROJECT_DIR/database/workflows.db" ]]; then
log "Backing up database..."
cp "$PROJECT_DIR/database/workflows.db" "$BACKUP_PATH/workflows.db"
success "Database backed up"
fi
# Backup configuration files
log "Backing up configuration..."
cp -r "$PROJECT_DIR"/*.yml "$BACKUP_PATH/" 2>/dev/null || true
cp "$PROJECT_DIR"/.env* "$BACKUP_PATH/" 2>/dev/null || true
cp -r "$PROJECT_DIR"/k8s "$BACKUP_PATH/" 2>/dev/null || true
cp -r "$PROJECT_DIR"/helm "$BACKUP_PATH/" 2>/dev/null || true
# Backup logs (last 7 days only)
if [[ -d "$PROJECT_DIR/logs" ]]; then
log "Backing up recent logs..."
find "$PROJECT_DIR/logs" -name "*.log" -mtime -7 -exec cp {} "$BACKUP_PATH/" \; 2>/dev/null || true
fi
# Create archive
log "Creating backup archive..."
cd "$BACKUP_DIR"
tar -czf "backup_$BACKUP_NAME.tar.gz" "backup_$BACKUP_NAME"
rm -rf "backup_$BACKUP_NAME"
# Cleanup old backups (keep last 10)
find "$BACKUP_DIR" -name "backup_*.tar.gz" -type f -printf '%T@ %p\n' | \
sort -rn | tail -n +11 | cut -d' ' -f2- | xargs rm -f
success "Backup created: $BACKUP_DIR/backup_$BACKUP_NAME.tar.gz"