Deploy scripts: compose version check, ovpmon_backup.db in native backups
Docker: variant B needs Docker Compose 2.17+ (additional_contexts); install.sh and update.sh check it in the preflight. Native: backup.sh, update.sh, restore.sh and --rollback now copy and restore ovpmon_backup.db (Backup and Restore settings) as an optional file. Verified install, update, backup, restore and rollback on Debian 12 (systemd), Alpine 3.23 (OpenRC) and both container variants. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f8cdcd0fc6
commit
3fac8d70d8
11 files changed
+178
-7
No files matched your search
@@ -31,7 +31,7 @@ Both variants use the **same five named volumes with the same in-container paths
|
||||
|
||||
## Requirements
|
||||
|
||||
- Docker Engine with the compose plugin (`docker compose`, v2, preferred) or `docker-compose`. **Variant B needs docker compose 2.17 or newer** (the profiler image is built with `additional_contexts`; the old `docker-compose` v1 does not support it). Variant A is not affected.
|
||||
- Docker Engine with the compose plugin (`docker compose`, v2, preferred) or `docker-compose`. **Variant B needs docker compose 2.17 or newer** (the profiler image is built with `additional_contexts`; the old `docker-compose` v1 does not support it). Variant A is not affected. `install.sh` and `update.sh` check this in the preflight (phase 0) and stop with a message that names the required and the found version; an unreadable version only gives a warning.
|
||||
- The Docker daemon running and usable by the user that runs the scripts (root, or a member of the `docker` group).
|
||||
- Access to `/dev/net/tun` on the host and the `NET_ADMIN` capability (already set in the compose files).
|
||||
- Free disk space: about 2 GB for images and builds, plus room for backups (the scripts check both).
|
||||
|
||||
@@ -37,7 +37,7 @@ Variables of the scripts (environment of the shell, not `.env`): `OVPMON_BACKUP_
|
||||
|
||||
`ovp_backups` is not one of the five data volumes: `deploy/docker/backup.sh` and `update.sh` do not copy it (packages are not put inside copies of the volumes). Back it up separately or use a remote destination. See [Backup and Restore](../../Profiler_Management/Backup_Restore.md).
|
||||
|
||||
Variant B, profiler image: besides `APP_PROFILER` it holds `/opt/core` (`migrations.py`, `migrate.py`, `db.py` of `APP_CORE`, standard library only; `OVPMON_CORE_DIR=/opt/core`), added at build time through the build context `core` (`additional_contexts` in `docker-compose.yml`, docker compose 2.17+). The restore of a backup package uses it to migrate the monitoring database of the package.
|
||||
Variant B, profiler image: besides `APP_PROFILER` it holds `/opt/core` (`migrations.py`, `migrate.py`, `db.py` of `APP_CORE`, standard library only; `OVPMON_CORE_DIR=/opt/core`), added at build time through the build context `core` (`additional_contexts` in `docker-compose.yml`, docker compose 2.17+; `install.sh` and `update.sh` check the version before the build). The restore of a backup package uses it to migrate the monitoring database of the package.
|
||||
|
||||
Not stored in volumes (lost when the container is recreated): the container file system, `profiler.log` and `openvpn_gatherer.log` (written into the working directory), supervisor state. Application logs go to `docker logs`.
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ Cron example (nightly, 14 kept): `30 3 * * * /opt/OpenVPN-Monitoring-Simple/depl
|
||||
| Content | File in the backup |
|
||||
|---|---|
|
||||
| both databases, consistent copies from the SQLite backup API (integrity-checked, owner and mode kept) | `db/monitor.db`, `db/profiler.db` |
|
||||
| `ovpmon_backup.db` (settings, destinations and encrypted secrets of the Backup and Restore page; next to the profiler database), same method; optional: skipped if the file does not exist | `db/backupcfg.db` |
|
||||
| `/etc/ovpmon` (environment, helper configuration, certificate, state) | `etc-ovpmon.tar.gz` |
|
||||
| `/etc/openvpn` (`server.conf`, `crl.pem`, scripts, `ipp.txt`) | `etc-openvpn.tar.gz` |
|
||||
| PKI `APP_PROFILER/easy-rsa` | `easy-rsa.tar.gz` |
|
||||
@@ -74,7 +75,7 @@ deploy/native/restore.sh /var/backups/ovpmon/20261005T101500Z # asks,
|
||||
deploy/native/restore.sh /var/backups/ovpmon/20261005T101500Z --yes --start
|
||||
```
|
||||
|
||||
It verifies the backup, stops the three application services, saves the **current state** to `/var/backups/ovpmon/<time>-pre-restore` (`OVPMON_NO_SAFETY_BACKUP=1` skips this), then restores code, databases, `/etc/ovpmon`, `/etc/openvpn`, PKI, client profiles, helper, service definitions, nginx site, UI and doas rules. A replaced database is kept as `<db>.failed-<time>`. OpenVPN is not stopped. On a new host run `install.sh` first, then `restore.sh`.
|
||||
It verifies the backup, stops the three application services, saves the **current state** to `/var/backups/ovpmon/<time>-pre-restore` (`OVPMON_NO_SAFETY_BACKUP=1` skips this), then restores code, databases, `/etc/ovpmon`, `/etc/openvpn`, PKI, client profiles, helper, service definitions, nginx site, UI and doas rules. A replaced database is kept as `<db>.failed-<time>`; `ovpmon_backup.db` is restored from `db/backupcfg.db` if the backup has it (backups of older versions do not: the live file is kept). The local backup packages of the Backup and Restore page (`/var/lib/ovpmon/backups`) are **not** part of the host backup. OpenVPN is not stopped. On a new host run `install.sh` first, then `restore.sh`.
|
||||
|
||||
Manual equivalent (services stopped, paths for the default prefix):
|
||||
|
||||
@@ -86,6 +87,7 @@ tar -xzpf $B/easy-rsa.tar.gz -C /opt/OpenVPN-Monitoring-Simple/APP_PROFILER
|
||||
tar -xzpf $B/client-config.tar.gz -C /opt/OpenVPN-Monitoring-Simple/APP_PROFILER
|
||||
cp -p $B/db/profiler.db /var/lib/ovpmon/ovpn_profiler.db # the backup was made with the sqlite backup API
|
||||
cp -p $B/db/monitor.db /var/lib/ovpmon/openvpn_monitor.db
|
||||
cp -p $B/db/backupcfg.db /var/lib/ovpmon/ovpmon_backup.db # only if the backup has it
|
||||
tar -xzpf $B/etc-ovpmon.tar.gz -C / && tar -xzpf $B/etc-openvpn.tar.gz -C /
|
||||
tar -xzpf $B/system.tar.gz -C / # helper, service definitions, nginx site
|
||||
```
|
||||
|
||||
@@ -13,7 +13,7 @@ Paths and owners, the environment file, the root helper configuration and securi
|
||||
| Profiler log | `<prefix>/APP_PROFILER/profiler.log` | `ovpmon:ovpmon` 640 |
|
||||
| Shipped settings file | `<prefix>/APP_CORE/config.ini`, `<prefix>/APP_PROFILER/config.ini` | `root:root`; the environment file overrides it |
|
||||
| **Databases** | `/var/lib/ovpmon/openvpn_monitor.db`, `ovpn_profiler.db`, migration copies `*.db.bak-*` | `ovpmon:ovpmon` |
|
||||
| **Local backup packages** (Backup and Restore page), `ovpmon_backup.db` | `/var/lib/ovpmon/backups/` (created by the service, folders 700, files 600; root set by `OVPMON_BACKUP_LOCAL_ROOT`), `/var/lib/ovpmon/ovpmon_backup.db` | `ovpmon:ovpmon` |
|
||||
| **Local backup packages** (Backup and Restore page), `ovpmon_backup.db` | `/var/lib/ovpmon/backups/` (created by the service, folders 700, files 600; root set by `OVPMON_BACKUP_LOCAL_ROOT`), `/var/lib/ovpmon/ovpmon_backup.db` (included in the host backup as `db/backupcfg.db`; the packages folder is not) | `ovpmon:ovpmon` |
|
||||
| Staging of `server.conf` | `/var/lib/ovpmon/staging/` | `ovpmon:ovpmon` 750 |
|
||||
| Service environment | `/etc/ovpmon/env` | `root:root` 600 |
|
||||
| Helper configuration | `/etc/ovpmon/helper.conf` | `root:root` 644 |
|
||||
|
||||
Reference in new issue
Block a user