Skip to content

AlexanderWagnerDev/all-inkl-hetzner-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

All-Inkl → Hetzner Storage Box Backup

License: MIT PHP Version

🇬🇧 English | 🇩🇪 Deutsch


English

Automated backup solution for All-Inkl webspace to Hetzner Storage Box via WebDAV. Single-file PHP script with web interface for monitoring and manual execution.

Features

  • 🚀 Simple Setup - Single PHP file, no dependencies
  • 🌐 Web Interface - Monitor backup progress in real-time
  • 🔒 Secure - HTTP Basic Auth protection
  • 📦 Efficient - Creates compressed tar.gz archives
  • Retention Management - Automatic cleanup of old backups (local & remote)
  • 📊 Live Logging - Real-time status updates during backup
  • 🔄 WebDAV Upload - Direct upload to Hetzner Storage Box

Requirements

  • PHP 8.0 or higher
  • All-Inkl webspace (or similar Linux hosting)
  • Hetzner Storage Box with WebDAV access
  • tar command available on server
  • cURL extension enabled

Installation

  1. Clone or download this repository to your webspace

  2. Copy configuration file

    cp .env.example .env
  3. Edit .env file with your credentials:

    BACKUP_AUTH_USER=your-webui-username
    BACKUP_AUTH_PASS=your-webui-password
    
    HETZNER_HOST=https://u123456.your-storagebox.de
    HETZNER_USER=your-storagebox-username
    HETZNER_PASS=your-storagebox-password
    
    LOCAL_KEEP_DAYS=3
    REMOTE_KEEP_DAYS=30
  4. Protect your .env file by creating/editing .htaccess:

    <Files ".env">
        Require all denied
    </Files>
  5. Access the script via your browser:

    https://yourdomain.com/path/to/backup.php
    

Configuration

Variable Description Default
BACKUP_AUTH_USER Username for web interface access -
BACKUP_AUTH_PASS Password for web interface access -
HETZNER_HOST Your Storage Box WebDAV URL -
HETZNER_USER Storage Box username -
HETZNER_PASS Storage Box password -
LOCAL_KEEP_DAYS Days to keep local backups 3
REMOTE_KEEP_DAYS Days to keep remote backups 30
BASE_DIR Webspace root directory Auto-detected

Usage

Manual Execution

  1. Open backup.php in your browser
  2. Click "Start backup"
  3. Monitor progress in real-time
  4. View full log by clicking "Open full log"

Automated Execution via All-Inkl Webcron

Method 1: Using Webcron (Recommended for All-Inkl)

  1. Log into your All-Inkl KAS (Kunden-Adminbereich)
  2. Navigate to Tools → Cronjobs
  3. Click "Neuer Cronjob" (New Cronjob)
  4. Configure as follows:
    • URL: https://yourdomain.com/path/to/backup.php?start=1
    • HTTP Auth Username: Your BACKUP_AUTH_USER from .env
    • HTTP Auth Password: Your BACKUP_AUTH_PASS from .env
    • Schedule: Daily at 2:00 AM (or preferred time)
    • E-Mail notification: Optional (receive execution status)

Method 2: Using External Cron Service

If you have access to an external server with cron:

# Daily backup at 2:00 AM
0 2 * * * curl -u "your-user:your-pass" "https://yourdomain.com/path/to/backup.php?start=1" > /dev/null 2>&1

Security Recommendations

⚠️ Important Security Notes:

  1. Always use HTTPS - Basic Auth credentials are transmitted in plain text
  2. Protect .env file - Use .htaccess to deny access
  3. Strong passwords - Use generated passwords with high entropy
  4. Regular updates - Keep PHP and server software up to date
  5. Backup verification - Regularly test backup restoration
  6. Webcron security - Use HTTP Auth in Webcron settings to prevent unauthorized access

File Structure

your-webspace/
├── backup.php           # Main script
├── .env                 # Configuration (DO NOT COMMIT!)
├── .env.example         # Example configuration
├── .htaccess            # Security rules
└── backup/              # Auto-created during first run
    ├── work/            # Temporary backup files
    ├── archive/         # Local backup archives
    └── backup.log       # Execution log

Excluded Directories

The following directories are automatically excluded from backups:

  • backup/ - Backup directory itself
  • cache/ - Cache directories
  • tmp/ - Temporary files

Troubleshooting

Backup fails immediately

  • Check PHP error log
  • Verify .env configuration
  • Ensure tar command is available: which tar
  • Check file permissions on backup directory

Upload fails

  • Verify Hetzner credentials
  • Test WebDAV connection manually
  • Check Storage Box available space
  • Ensure cURL extension is enabled

Timeout issues

  • Increase max_execution_time in PHP configuration
  • Reduce backup size by excluding more directories
  • Webcron typically has better timeout limits than browser execution

Memory errors

  • Increase memory_limit in PHP configuration
  • Archive size might exceed available memory

Webcron not working

  • Verify HTTP Auth credentials in Webcron settings
  • Check if URL is accessible (test manually with Basic Auth)
  • Review Webcron execution log in KAS interface

Known Limitations

  • Remote cleanup (Hetzner Storage Box) is not yet implemented
  • No concurrent execution protection (lock mechanism)
  • Large archives may cause memory issues
  • Basic Auth is not encrypted (requires HTTPS)

Roadmap

  • Implement remote backup cleanup via WebDAV PROPFIND
  • Add lock mechanism to prevent concurrent executions
  • Email notifications on success/failure
  • Database backup integration (MySQL/MariaDB)
  • Incremental backup support
  • Multi-destination backup support

License

MIT License - see LICENSE file

Author

Alexander Wagner (@AlexanderWagnerDev)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


Deutsch

Automatisierte Backup-Lösung für All-Inkl Webspace zu Hetzner Storage Box via WebDAV. Einzelnes PHP-Skript mit Web-Interface zur Überwachung und manuellen Ausführung.

Features

  • 🚀 Einfache Installation - Einzelne PHP-Datei, keine Abhängigkeiten
  • 🌐 Web-Interface - Backup-Fortschritt in Echtzeit überwachen
  • 🔒 Sicher - HTTP Basic Auth Schutz
  • 📦 Effizient - Erstellt komprimierte tar.gz Archive
  • Aufbewahrungsmanagement - Automatisches Löschen alter Backups (lokal & remote)
  • 📊 Live-Logging - Echtzeit-Statusupdates während des Backups
  • 🔄 WebDAV-Upload - Direkter Upload zur Hetzner Storage Box

Voraussetzungen

  • PHP 8.0 oder höher
  • All-Inkl Webspace (oder ähnliches Linux-Hosting)
  • Hetzner Storage Box mit WebDAV-Zugang
  • tar Befehl auf dem Server verfügbar
  • cURL Extension aktiviert

Installation

  1. Repository klonen oder herunterladen auf deinen Webspace

  2. Konfigurationsdatei kopieren

    cp .env.example .env
  3. .env Datei bearbeiten mit deinen Zugangsdaten:

    BACKUP_AUTH_USER=dein-webui-benutzername
    BACKUP_AUTH_PASS=dein-webui-passwort
    
    HETZNER_HOST=https://u123456.your-storagebox.de
    HETZNER_USER=dein-storagebox-benutzername
    HETZNER_PASS=dein-storagebox-passwort
    
    LOCAL_KEEP_DAYS=3
    REMOTE_KEEP_DAYS=30
  4. .env Datei schützen durch Erstellen/Bearbeiten der .htaccess:

    <Files ".env">
        Require all denied
    </Files>
  5. Skript aufrufen über deinen Browser:

    https://deinedomain.de/pfad/zu/backup.php
    

Konfiguration

Variable Beschreibung Standard
BACKUP_AUTH_USER Benutzername für Web-Interface-Zugang -
BACKUP_AUTH_PASS Passwort für Web-Interface-Zugang -
HETZNER_HOST Deine Storage Box WebDAV-URL -
HETZNER_USER Storage Box Benutzername -
HETZNER_PASS Storage Box Passwort -
LOCAL_KEEP_DAYS Tage zum Aufbewahren lokaler Backups 3
REMOTE_KEEP_DAYS Tage zum Aufbewahren Remote-Backups 30
BASE_DIR Webspace-Hauptverzeichnis Auto-erkannt

Verwendung

Manuelle Ausführung

  1. Öffne backup.php im Browser
  2. Klicke auf "Start backup"
  3. Überwache den Fortschritt in Echtzeit
  4. Vollständiges Log anzeigen durch Klick auf "Open full log"

Automatisierte Ausführung via All-Inkl Webcron

Methode 1: Webcron verwenden (Empfohlen für All-Inkl)

  1. Melde dich im All-Inkl KAS (Kunden-Adminbereich) an
  2. Navigiere zu Tools → Cronjobs
  3. Klicke auf "Neuer Cronjob"
  4. Konfiguriere wie folgt:
    • URL: https://deinedomain.de/pfad/zu/backup.php?start=1
    • HTTP Auth Benutzername: Dein BACKUP_AUTH_USER aus der .env
    • HTTP Auth Passwort: Dein BACKUP_AUTH_PASS aus der .env
    • Zeitplan: Täglich um 2:00 Uhr (oder gewünschte Zeit)
    • E-Mail Benachrichtigung: Optional (Ausführungsstatus erhalten)

Methode 2: Externer Cron-Service

Falls du Zugriff auf einen externen Server mit Cron hast:

# Tägliches Backup um 2:00 Uhr
0 2 * * * curl -u "dein-user:dein-pass" "https://deinedomain.de/pfad/zu/backup.php?start=1" > /dev/null 2>&1

Sicherheitsempfehlungen

⚠️ Wichtige Sicherheitshinweise:

  1. Immer HTTPS verwenden - Basic Auth Zugangsdaten werden im Klartext übertragen
  2. .env Datei schützen - Verwende .htaccess um Zugriff zu verweigern
  3. Starke Passwörter - Nutze generierte Passwörter mit hoher Entropie
  4. Regelmäßige Updates - Halte PHP und Server-Software aktuell
  5. Backup-Verifikation - Teste regelmäßig die Wiederherstellung
  6. Webcron-Sicherheit - Nutze HTTP Auth in den Webcron-Einstellungen um unautorisierten Zugriff zu verhindern

Dateistruktur

dein-webspace/
├── backup.php           # Hauptskript
├── .env                 # Konfiguration (NICHT COMMITTEN!)
├── .env.example         # Beispiel-Konfiguration
├── .htaccess            # Sicherheitsregeln
└── backup/              # Wird beim ersten Lauf automatisch erstellt
    ├── work/            # Temporäre Backup-Dateien
    ├── archive/         # Lokale Backup-Archive
    └── backup.log       # Ausführungsprotokoll

Ausgeschlossene Verzeichnisse

Folgende Verzeichnisse werden automatisch vom Backup ausgeschlossen:

  • backup/ - Backup-Verzeichnis selbst
  • cache/ - Cache-Verzeichnisse
  • tmp/ - Temporäre Dateien

Fehlersuche

Backup schlägt sofort fehl

  • PHP Error Log prüfen
  • .env Konfiguration verifizieren
  • Sicherstellen dass tar verfügbar ist: which tar
  • Dateiberechtigungen im Backup-Verzeichnis prüfen

Upload schlägt fehl

  • Hetzner-Zugangsdaten überprüfen
  • WebDAV-Verbindung manuell testen
  • Verfügbaren Speicherplatz auf Storage Box prüfen
  • Sicherstellen dass cURL Extension aktiviert ist

Timeout-Probleme

  • max_execution_time in PHP-Konfiguration erhöhen
  • Backup-Größe durch Ausschluss weiterer Verzeichnisse reduzieren
  • Webcron hat typischerweise bessere Timeout-Limits als Browser-Ausführung

Speicherfehler

  • memory_limit in PHP-Konfiguration erhöhen
  • Archiv-Größe könnte verfügbaren Speicher überschreiten

Webcron funktioniert nicht

  • HTTP Auth Zugangsdaten in Webcron-Einstellungen überprüfen
  • Prüfen ob URL erreichbar ist (manuell mit Basic Auth testen)
  • Webcron-Ausführungslog im KAS-Interface überprüfen

Bekannte Einschränkungen

  • Remote-Cleanup (Hetzner Storage Box) ist noch nicht implementiert
  • Kein Schutz vor gleichzeitiger Ausführung (Lock-Mechanismus)
  • Große Archive können Speicherprobleme verursachen
  • Basic Auth ist unverschlüsselt (erfordert HTTPS)

Roadmap

  • Remote-Backup-Cleanup via WebDAV PROPFIND implementieren
  • Lock-Mechanismus zur Verhinderung gleichzeitiger Ausführungen
  • E-Mail-Benachrichtigungen bei Erfolg/Fehler
  • Datenbank-Backup-Integration (MySQL/MariaDB)
  • Inkrementelle Backup-Unterstützung
  • Multi-Ziel-Backup-Unterstützung

Lizenz

MIT License - siehe LICENSE Datei

Autor

Alexander Wagner (@AlexanderWagnerDev)

Mitwirken

Beiträge sind willkommen! Bitte reiche einen Pull Request ein.


Support

🇬🇧 If you encounter any issues or have questions, please open an issue on GitHub.

🇩🇪 Bei Problemen oder Fragen öffne bitte ein Issue auf GitHub.

About

🔄 Automated backup solution for All-Inkl webspace to Hetzner Storage Box via WebDAV | Automatisches Backup-System mit Web-Interface und Webcron-Support

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages