Add optional greenfield installation to restore menu

New restore menu option sets up a fresh Debian/Ubuntu server (packages,
PostgreSQL role/database, Redis, netbox user, systemd units, optional
nginx with self-signed cert) and then runs a full restore.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
MrBlakeandClaude Opus 5.5 committed 2026-11-13 13:01:57 +01:00
1 parent f132d8878d
commit e3f550f17a
3 files changed
+248 -12

No files matched your search

+21 -2
View File
@@ -320,8 +320,9 @@ Main menu → `2. Restore-Menü`.
2. Nur Datenbank wiederherstellen (database only)
3. Nur Media-Dateien wiederherstellen (media only)
4. Nur Installationsdateien wiederherstellen (installation files only)
5. Backup-Inhalt anzeigen (show backup contents)
6. Zurück zum Hauptmenü (back)
5. Neuinstallation auf grüner Wiese (...) (greenfield install + full restore)
6. Backup-Inhalt anzeigen (show backup contents)
7. Zurück zum Hauptmenü (back)
```
Restore must be run as `root` / with `sudo`.
@@ -357,6 +358,24 @@ The current installation is never deleted:
| `/opt/netbox` is a directory | current installation is renamed to `/opt/netbox_before_restore_<timestamp>`, the restored files take its place |
| `/opt/netbox` is a symlink | restored files go to `/opt/netbox-<version>-restored-<timestamp>`, the symlink is switched atomically; the previous target stays |
### Greenfield installation (optional)
Menu item `5` restores a backup onto a fresh Debian/Ubuntu server with no existing NetBox. The backup must contain installation files and the database (format 1.3 or newer).
Before the full restore, the tool sets up:
1. System packages via `apt-get` (PostgreSQL, Redis, Python incl. `venv`/`dev`, build dependencies, Git).
2. PostgreSQL role `db_user` (`LOGIN CREATEDB`, password `db_pass`) and database `db_name`. If `db_pass` is empty, it is prompted for.
3. System user `netbox`, if missing.
After the restore and `upgrade.sh`:
4. `gunicorn.py` and the systemd units from `contrib/` are copied to `/etc/systemd/system` (existing ones are not overwritten) and enabled.
5. Optionally nginx using `contrib/nginx.conf` with a self-signed certificate (`/etc/ssl/certs/netbox.crt`).
> [!IMPORTANT]
> `db_name`, `db_user`, `db_pass` and `netbox_path` must match the `configuration.py` in the backup, and `db_host` must be `localhost`. Replace the self-signed certificate with a real one later.
### Required database privileges
The configured database user must be allowed to run `dropdb` and `createdb`.