1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-10 04:06:47 +00:00

feat(appsettings): the panel backs itself up every day

The only backups of the panel were the ones taken by hand before an
update. Now `manage.py backup` writes a new directory under backups/
with a consistent copy of the sqlite database (the backup API, while
the panel runs, checked with PRAGMA integrity_check), the secret key,
the worker's node_id, settings.py, the SSH keys of the panel's user
and, outside Docker, the commit. It keeps the newest 7 (--keep N) and
deletes older ones only after a good backup; a failed one leaves
nothing, and a second run while one runs fails. Files are mode 600,
directories 700: the database holds compute passwords and keys. With
PostgreSQL the database is left out.

It runs daily at 03:15: in Docker from the image's cron into a new
volume, webvirtcloud-backups; otherwise from webvirt-backup.timer,
which the installer and the manual steps install. A backup has the
layout of the update backups, so the restore steps take either.
This commit is contained in:
catborise 2026-11-03 09:32:34 +03:00
parent 6ca65e291a
commit 777057cb19
12 changed files with 264 additions and 24 deletions

View file

@ -210,11 +210,13 @@ configure_nginx () {
configure_systemd () {
# The panel's services run as the web server's user; a re-run restarts them.
units="webvirt-cloud webvirt-novncd webvirt-socketiod webvirt-worker"
for unit in $units; do
for unit in $units webvirt-backup; do
sed "s/^\\(User\\|Group\\)=.*/\\1=$nginx_group/" "$APP_PATH/conf/systemd/$unit.service" > "/etc/systemd/system/$unit.service" || exit 1
done
cp "$APP_PATH/conf/systemd/webvirt-backup.timer" /etc/systemd/system/ || exit 1
# shellcheck disable=SC2086
systemctl daemon-reload && systemctl enable $units && systemctl restart $units || exit 1
systemctl daemon-reload && systemctl enable $units && systemctl restart $units &&
systemctl enable --now webvirt-backup.timer || exit 1
}
create_user () {