feat(backup): GUI-konfigurierbares, verschlüsseltes Off-Site-Backup (SFTP/Nextcloud) (v1.9.0)
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 54m48s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 54m48s
Admin → Backup: Ziel (SFTP oder Nextcloud/WebDAV) konfigurieren, Verbindung testen, Jetzt sichern,
Zeitplan (aus/täglich/wöchentlich) + Aufbewahrung. Best Practice: verschlüsselt + off-site.
- Verschlüsselung: Backup als tar.gz (database.dump + MinIO-Dateien) → AES-256-GCM mit Passphrase.
Zugangsdaten + Passphrase verschlüsselt in DB (src/lib/crypto-secret.ts, Schlüssel aus Server-Secret)
- Engine (src/lib/backup): pg_dump + archiver-Stream aus MinIO + Stream-Verschlüsselung + Upload + Prune
- Ziel-Adapter: SFTP (ssh2-sftp-client) + WebDAV (webdav), je test/upload/list/delete
- API (SERVER_ADMIN): /api/admin/backup/{config,test,run}; öffentlich per CRON_SECRET: /api/cron/backup
- Scheduler in server-custom.js (stündliche Fälligkeitsprüfung)
- Dockerfile: postgresql16-client (pg_dump) + runtime-Libs; next.config serverExternalPackages
- scripts/decrypt-backup.js + docs/BACKUP.md (Restore-Anleitung), .env.example (CRON_SECRET, BACKUP_ENC_KEY)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -71,4 +71,21 @@ app.prepare().then(() => {
|
||||
httpServer.listen(port, hostname, () => {
|
||||
console.log(`> Ready on http://${hostname}:${port}`)
|
||||
})
|
||||
|
||||
// Backup-Scheduler: stündlich prüfen, ob laut Zeitplan ein Backup fällig ist.
|
||||
// Die Route /api/cron/backup entscheidet anhand der Konfiguration; hier wird nur getriggert.
|
||||
if (process.env.CRON_SECRET) {
|
||||
const checkBackup = () => {
|
||||
fetch(`http://127.0.0.1:${port}/api/cron/backup`, {
|
||||
method: 'POST',
|
||||
headers: { 'x-cron-secret': process.env.CRON_SECRET },
|
||||
})
|
||||
.then((r) => r.json())
|
||||
.then((d) => { if (d && d.skipped !== true) console.log('[backup-scheduler]', JSON.stringify(d)) })
|
||||
.catch((e) => console.warn('[backup-scheduler]', e.message))
|
||||
}
|
||||
setInterval(checkBackup, 60 * 60 * 1000) // stündlich
|
||||
setTimeout(checkBackup, 90 * 1000) // ~1.5 Min nach Start einmal
|
||||
console.log('> Backup-Scheduler aktiv (stündliche Fälligkeitsprüfung)')
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user