mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 08:50:12 -08:00
4.4 KiB
4.4 KiB
Backup Web Application Deployment Guide
This guide covers multiple methods to keep the backup web application running perpetually on your server.
Deployment Options
1. 🚀 Systemd Service (Recommended for Production)
Best for: Production environments, automatic startup on boot, proper logging, and system integration.
Setup Steps:
# Install the service
sudo ./manage-backup-web-service.sh install
# Start the service
sudo ./manage-backup-web-service.sh start
# Check status
./manage-backup-web-service.sh status
# View logs
./manage-backup-web-service.sh logs
Service Management:
# Start/Stop/Restart
sudo systemctl start backup-web-app
sudo systemctl stop backup-web-app
sudo systemctl restart backup-web-app
# Enable/Disable auto-start on boot
sudo systemctl enable backup-web-app
sudo systemctl disable backup-web-app
# Check logs
sudo journalctl -u backup-web-app -f
2. 🐳 Docker (Recommended for Isolation)
Best for: Containerized environments, easy deployment, consistent runtime.
Using Docker Compose:
# Build and start
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose down
# Rebuild and restart
docker-compose up -d --build
Using Docker directly:
# Build image
docker build -t backup-web-app .
# Run container
docker run -d \
--name backup-web-app \
-p 5000:5000 \
-v /mnt/share/media/backups:/data/backups:ro \
-e BACKUP_ROOT=/data/backups \
--restart unless-stopped \
backup-web-app
3. 📺 Screen Session (Quick & Simple)
Best for: Development, testing, quick deployments.
# Start the application
./run-backup-web-screen.sh start
# Check status
./run-backup-web-screen.sh status
# View logs (connect to session)
./run-backup-web-screen.sh logs
# Stop the application
./run-backup-web-screen.sh stop
4. ⚡ Production with Gunicorn
Best for: High-performance production deployments.
# Install gunicorn
pip install gunicorn
# Run with production settings
./run-production.sh
Configuration
Environment Variables
BACKUP_ROOT: Path to backup directory (default:/mnt/share/media/backups)PORT: Application port (default:5000)FLASK_ENV: Environment mode (developmentorproduction)FLASK_DEBUG: Enable debug mode (trueorfalse)
Security Considerations
- Firewall: Ensure port 5000 is properly secured
- Reverse Proxy: Consider using nginx for SSL termination
- Authentication: Add authentication for production use
- File Permissions: Ensure proper read permissions for backup directories
Monitoring & Maintenance
Health Checks
The application provides a health endpoint:
curl http://localhost:5000/health
Log Locations
- Systemd:
sudo journalctl -u backup-web-app - Docker:
docker-compose logsordocker logs backup-web-app - Screen: Connect to session with
screen -r backup-web-app - Gunicorn:
/tmp/backup-web-app-access.logand/tmp/backup-web-app-error.log
Automatic Restarts
- Systemd: Built-in restart on failure
- Docker: Use
--restart unless-stoppedorrestart: unless-stoppedin compose - Screen: Manual restart required
Troubleshooting
Common Issues
-
Port already in use:
sudo lsof -i :5000 sudo netstat -tulpn | grep :5000 -
Permission denied for backup directory:
sudo chown -R acedanger:acedanger /mnt/share/media/backups chmod -R 755 /mnt/share/media/backups -
Service won't start:
sudo journalctl -u backup-web-app -n 50
Performance Tuning
- Gunicorn Workers: Adjust in
gunicorn.conf.py - Memory Limits: Set in systemd service or docker-compose
- Log Rotation: Configure logrotate for production
Quick Start Commands
# For development/testing (Screen)
./run-backup-web-screen.sh start
# For production (Systemd)
sudo ./manage-backup-web-service.sh install
sudo ./manage-backup-web-service.sh start
# For containerized (Docker)
docker-compose up -d
# Check if running
curl http://localhost:5000/health
Recommended Setup
For a production server, use this combination:
- Primary: Systemd service for reliability
- Backup: Docker setup for easy maintenance
- Monitoring: Set up log monitoring and alerts
- Security: Add reverse proxy with SSL
Choose the method that best fits your infrastructure and requirements!