Initial commit

This commit is contained in:
Alexander Doerflinger
2026-02-20 09:10:27 +01:00
commit 2ffcbb5f60
11 changed files with 1068 additions and 0 deletions

82
scripts/restore.sh Normal file
View File

@@ -0,0 +1,82 @@
#!/usr/bin/env bash
###############################################################################
# restore.sh — Restore home-server stack data from a backup archive
#
# Usage:
# ./scripts/restore.sh <backup-file.tar.gz>
#
# This will extract the backup into the project directory, overwriting
# existing service data.
###############################################################################
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
if [ $# -lt 1 ]; then
echo -e "${RED}Usage: $0 <backup-file.tar.gz>${NC}"
echo ""
echo "Available backups:"
if [ -d "$PROJECT_DIR/backups" ]; then
ls -lh "$PROJECT_DIR/backups/"*.tar.gz 2>/dev/null || echo " (none found)"
else
echo " (no backups directory)"
fi
exit 1
fi
BACKUP_FILE="$1"
if [ ! -f "$BACKUP_FILE" ]; then
echo -e "${RED}ERROR: Backup file not found: $BACKUP_FILE${NC}"
exit 1
fi
echo -e "${YELLOW}=== Home Server Restore ===${NC}"
echo "Backup: $BACKUP_FILE"
echo "Target: $PROJECT_DIR"
echo ""
# Check if services are running
if command -v docker &> /dev/null; then
RUNNING=$(docker compose -f "$PROJECT_DIR/docker-compose.yml" ps --status running -q 2>/dev/null | wc -l)
if [ "$RUNNING" -gt 0 ]; then
echo -e "${RED}ERROR: $RUNNING container(s) are still running.${NC}"
echo "Please stop all services before restoring:"
echo " docker compose down"
exit 1
fi
fi
echo -e "${YELLOW}WARNING: This will overwrite existing data in:${NC}"
echo " - nginx-proxy-manager/"
echo " - homeassistant/"
echo " - gitea/"
echo " - wireguard/"
echo " - .env"
echo ""
read -p "Are you sure? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Restore cancelled."
exit 0
fi
echo ""
echo "Extracting backup..."
tar -xzf "$BACKUP_FILE" -C "$PROJECT_DIR"
echo ""
echo -e "${GREEN}=== Restore complete ===${NC}"
echo ""
echo "Next steps:"
echo " 1. Review your .env file and adjust if needed"
echo " 2. Start services: docker compose up -d"
echo " 3. Verify all services: docker compose ps"