1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

feat(appsettings): the panel backup dumps a PostgreSQL database

With PostgreSQL the daily backup left the database out and only warned. It now
writes a pg_dump in its custom format as db.pgdump and fails when pg_dump is
missing or the dump fails. The Docker image ships postgresql-client; the restore
and move steps say how to put the dump back.
This commit is contained in:
catborise 2026-11-25 13:56:04 +03:00
parent b4c7ecddc4
commit 2b5d0ac80e
6 changed files with 67 additions and 19 deletions

View file

@ -7,7 +7,8 @@
The panel backs itself up every day at 03:15 (cron in Docker; otherwise `webvirt-backup.timer`, within 10 minutes after and at the next boot if the server was off) into a new directory under `/srv/webvirtcloud/backups`, in Docker the `webvirtcloud-backups` volume, and keeps the newest 7. A backup holds:
- `db.sqlite3`: a consistent copy taken while the panel runs, checked with `PRAGMA integrity_check`; with PostgreSQL it is left out, so back up that database yourself
- `db.sqlite3`: a consistent copy taken while the panel runs, checked with `PRAGMA integrity_check`
- `db.pgdump` instead, with PostgreSQL: a `pg_dump` of the database in its custom format. The Docker image has `pg_dump`; otherwise install the PostgreSQL client (`postgresql-client` on Debian and Ubuntu, `postgresql` on RHEL), of the server's major version or newer. Without it the backup fails
- `secret_key`, `node_id` and `local_settings.py`
- `ssh/`: the SSH keys of the panel's user, which the SSH computes accept
- `pki/`: the TLS client certificates of the panel's user, which the TLS computes accept

View file

@ -16,7 +16,7 @@ What an update from an older version changes for operators and users. To run the
- gstfsd does only what the panel signs with the host's key: it does not start without `GSTFSD_KEY` in `/etc/default/webvirt-gstfsd`. On every compute, update gstfsd and its unit and make the key as in [Adding a Compute Node, step 3](compute-nodes.md#3-install-gstfsd) (a remote panel's `GSTFSD_BIND_HOST` and `GSTFSD_ALLOW_REMOTE` move into that file from `systemctl edit webvirt-gstfsd`), then enter the key on each compute's edit page.
- LDAP login's packages are in `conf/requirements-ldap.txt` and no longer installed by default, nor their build headers by the installer; the Docker image keeps them. An existing virtualenv keeps them, but only installing that file updates them (see [LDAP](ldap.md)).
- The themes ship compiled; picking one on the Settings page only saves its name, and the "Theme SASS Path" setting is gone. Browsers revalidate static files on each load: files cached before the update can stay until a hard reload (Ctrl+F5) of each page; an external caching proxy may need a purge.
- The panel backs itself up every day ([Backups](backups.md)); in Docker into a new volume, `webvirtcloud-backups`.
- The panel backs itself up every day ([Backups](backups.md)); in Docker into a new volume, `webvirtcloud-backups`. With PostgreSQL the backup holds a `pg_dump` of the database and fails without `pg_dump`: outside Docker, install the PostgreSQL client.
- The Docker image is built on Ubuntu 26.04 LTS (Python 3.14, libvirt 12) instead of 24.04; `docker compose up -d --build` rebuilds it.
- New passwords must pass Django's password validators: at least 8 characters, not a common password, not only digits, not like the user's name or e-mail. Existing passwords keep working.
- In Docker, the TLS client certificates of TLS computes are kept in a new volume, `webvirtcloud-pki` (`/var/www/.pki`), and backed up; put them there once ([Adding a Compute Node, TLS](compute-nodes.md#tls)).

View file

@ -70,7 +70,7 @@ From a root shell:
## Restore and rollback
Restoring puts back the database as it was at the backup; changes made since are lost. Migrations are not reversed. This covers sqlite; restore a PostgreSQL database from your own backup before rolling back the code. Set `b` to the backup directory to restore. To restore the database without rolling back the code, leave out the `build` line and every line that takes another file from `$b`: the commit, `local-migrations.tar`, `settings.py` and `local_settings.py`, the nginx config and `/etc/default/webvirtcloud`.
Restoring puts back the database as it was at the backup; changes made since are lost. Migrations are not reversed. With PostgreSQL, restore the database from the backup's `db.pgdump` before rolling back the code, as in [Restoring a PostgreSQL database](#restoring-a-postgresql-database), and leave out the line below that restores `db.sqlite3`. Set `b` to the backup directory to restore. To restore the database without rolling back the code, leave out the `build` line and every line that takes another file from `$b`: the commit, `local-migrations.tar`, `settings.py` and `local_settings.py`, the nginx config and `/etc/default/webvirtcloud`.
Docker, in the directory you installed from:
@ -123,9 +123,19 @@ nginx -t && systemctl reload nginx && systemctl start webvirt-cloud webvirt-novn
A version from before v3.0.0 has no worker: `systemctl disable --now webvirt-worker`. A rollback keeps the systemd units, and drops what a stopped `update.sh` kept to go on with (`data/.update-backup`). A rollback leaves the clone on a detached HEAD at the restored commit; `update.sh` records that commit before it switches back to `master`.
### Restoring a PostgreSQL database
With the panel stopped, from a shell with the PostgreSQL client and the `WEBVIRTCLOUD_DB_*` values the panel uses. The first command empties the database, also of tables a later version added:
```bash
export PGPASSWORD="$WEBVIRTCLOUD_DB_PASSWORD" &&
psql -h "$WEBVIRTCLOUD_DB_HOST" -U webvirtcloud -d webvirtcloud -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public" &&
pg_restore --no-owner -h "$WEBVIRTCLOUD_DB_HOST" -U webvirtcloud -d webvirtcloud "$b/db.pgdump"
```
## Moving to a new machine
A [backup](backups.md) moves the panel to a new machine, or back onto lost volumes: the database, the secret key (signed-in users stay signed in), the worker's id and the SSH keys and TLS certificates the computes accept. Install the panel there first, the same version or a newer one, then copy the backup directory over and set `b` to it. The backup does not hold `docker-compose.override.yml`, the nginx config or `/etc/default/webvirtcloud`: bring your own lines over yourself. Users sign in with their passwords from the backup; the new installation's `data/admin_password` no longer applies. The backup's `secret_key` is the key in use, also one set as `SECRET_KEY` in the environment. With PostgreSQL, restore that database yourself and leave out the line below that restores `db.sqlite3` (the backup has none), and stop the old panel before the new one starts: both would run the jobs of the one database.
A [backup](backups.md) moves the panel to a new machine, or back onto lost volumes: the database, the secret key (signed-in users stay signed in), the worker's id and the SSH keys and TLS certificates the computes accept. Install the panel there first, the same version or a newer one, then copy the backup directory over and set `b` to it. The backup does not hold `docker-compose.override.yml`, the nginx config or `/etc/default/webvirtcloud`: bring your own lines over yourself. Users sign in with their passwords from the backup; the new installation's `data/admin_password` no longer applies. The backup's `secret_key` is the key in use, also one set as `SECRET_KEY` in the environment. With PostgreSQL, restore the backup's `db.pgdump` as in [Restoring a PostgreSQL database](#restoring-a-postgresql-database) and leave out the line below that restores `db.sqlite3` (the backup has none); stop the old panel before the new one starts: both would run the jobs of the one database.
Docker, in the directory you installed from: