Major addition: Full Docker implementation for Windows, macOS, and Linux support New Features: - Docker container with PBS client in Debian environment - Platform-specific docker-compose files (linux/windows/macos) - Daemon mode with internal cron scheduler - One-shot backup mode for manual execution - Optional REST API server for remote management - Health monitoring and status endpoints - Automatic encryption key generation and management Docker Structure: - docker/Dockerfile - Container build definition - docker/scripts/ - Entrypoint, backup, healthcheck, and API scripts - docker/build.sh - Build script for Docker image - docker/deploy.sh - Interactive deployment script - docker/docker-compose-*.yml - Platform-specific configurations Documentation: - docker/README-DOCKER.md - Complete Docker documentation - docker/QUICKSTART-DOCKER.md - Quick start guide - docker/DOCKER-SOLUTION-SUMMARY.md - Architecture overview - BACKUP-TYPES-GUIDE.md - File vs block device backup guide Updated: - README.md - Added cross-platform support section and platform matrix - CHANGELOG.md - Documented all Docker features This enables PBSClientTool to backup Windows and Mac systems via Docker, while maintaining native Linux performance for full disk images. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
79 lines
2 KiB
Bash
Executable file
79 lines
2 KiB
Bash
Executable file
#!/bin/bash
|
|
# Simple API server for PBS Client container management
|
|
# Provides REST endpoints for status, manual backup, etc.
|
|
|
|
PORT=${API_PORT:-8080}
|
|
|
|
log() {
|
|
echo "[API] [$(date +'%Y-%m-%d %H:%M:%S')] $1"
|
|
}
|
|
|
|
# Function to handle HTTP requests
|
|
handle_request() {
|
|
local method="$1"
|
|
local path="$2"
|
|
|
|
case "$path" in
|
|
/status)
|
|
if [ -f /logs/status.json ]; then
|
|
cat /logs/status.json
|
|
else
|
|
echo '{"error":"No backup status available"}'
|
|
fi
|
|
;;
|
|
/health)
|
|
if /usr/local/bin/healthcheck >/dev/null 2>&1; then
|
|
echo '{"status":"healthy"}'
|
|
else
|
|
echo '{"status":"unhealthy"}'
|
|
fi
|
|
;;
|
|
/backup)
|
|
if [ "$method" = "POST" ]; then
|
|
echo '{"status":"starting","message":"Backup triggered"}'
|
|
/usr/local/bin/pbs-backup &
|
|
else
|
|
echo '{"error":"Use POST method to trigger backup"}'
|
|
fi
|
|
;;
|
|
/logs)
|
|
if [ -f /logs/last-backup.log ]; then
|
|
tail -n 50 /logs/last-backup.log | jq -R -s -c 'split("\n")'
|
|
else
|
|
echo '{"logs":[]}'
|
|
fi
|
|
;;
|
|
*)
|
|
echo '{"error":"Not found","available_endpoints":["/status","/health","/backup","/logs"]}'
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# Simple HTTP server using nc
|
|
log "Starting API server on port $PORT"
|
|
|
|
while true; do
|
|
{
|
|
read -r method path protocol
|
|
|
|
# Read headers (discard)
|
|
while read -r line; do
|
|
[ -z "$line" ] || [ "$line" = $'\r' ] && break
|
|
done
|
|
|
|
# Generate response
|
|
RESPONSE=$(handle_request "$method" "$path")
|
|
CONTENT_LENGTH=${#RESPONSE}
|
|
|
|
# Send HTTP response
|
|
cat << EOF
|
|
HTTP/1.1 200 OK
|
|
Content-Type: application/json
|
|
Content-Length: $CONTENT_LENGTH
|
|
Access-Control-Allow-Origin: *
|
|
Connection: close
|
|
|
|
$RESPONSE
|
|
EOF
|
|
} | nc -l -p $PORT -q 1
|
|
done
|