# Backups 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 - `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 - `commit`, outside Docker The database holds compute passwords and keys: the directories are readable only by the panel's user. They are on the same host as the panel; the [off-site copy](#off-site-copy) keeps them on another server too. A failed backup is reported in `docker logs` or by `systemctl status webvirt-backup` and deletes no older backup. Take one now: ```bash docker compose exec -u www-data webvirtcloud venv/bin/python3 manage.py backup # Docker systemctl start webvirt-backup && journalctl -u webvirt-backup -n 3 # otherwise ``` To restore one, follow [Restore and rollback](upgrading.md#restore-and-rollback) with `b` set to its directory. In Docker, copy it out of the volume first (`docker compose cp webvirtcloud:/srv/webvirtcloud/backups/webvirtcloud-backup-YYYYMMDD-HHMMSS ..`) and leave out the `git checkout` and `build` lines: the backup has no commit. To move the panel to a new machine, see [Moving to a new machine](upgrading.md#moving-to-a-new-machine). ## Off-site copy `webvirt-offsite.timer` copies the backups every day at 03:45 with [restic](https://restic.net) over SFTP to another server, encrypted with a password that only you and the panel's host hold, and keeps 7 daily, 4 weekly and 6 monthly copies there. It runs on the panel's host as root, also with Docker. It fails, and `journalctl -u webvirt-offsite` says why, when the newest backup is older than 26 hours or the copy does not finish. On the other server, create the user the copies go to (`wvcbackup` on `backup.example.com` below): ```bash useradd -m wvcbackup && install -d -o wvcbackup -m 700 ~wvcbackup/.ssh ``` On the panel's host, from a root shell in the panel's checkout (`/srv/webvirtcloud`, or the clone Docker runs from): 1. Install restic and curl (RHEL: `dnf -y install epel-release && dnf -y install restic`, openSUSE: `zypper -n install restic curl`) and the job: ```bash apt-get -y install restic curl install -m 755 conf/webvirt-offsite.sh /usr/local/sbin/webvirt-offsite cp conf/systemd/webvirt-offsite.service conf/systemd/webvirt-offsite.timer /etc/systemd/system/ ``` 2. Give the host a key of its own for the other server: ```bash install -d -m 700 /root/.ssh ssh-keygen -q -t ed25519 -N '' -f /root/.ssh/webvirtcloud-offsite cat >> /root/.ssh/config <<'EOF' Host webvirtcloud-offsite HostName backup.example.com User wvcbackup IdentityFile /root/.ssh/webvirtcloud-offsite EOF ``` Add `/root/.ssh/webvirtcloud-offsite.pub` to `~wvcbackup/.ssh/authorized_keys` on the other server (owned by `wvcbackup`, mode 600), then connect once to record the server's key: ```bash ssh -o StrictHostKeyChecking=accept-new webvirtcloud-offsite true ``` 3. Write the settings with a new password and create the repository. With Docker, set `WVC_BACKUPS` to the volume, `$(docker volume inspect -f '{{.Mountpoint}}' webvirtcloud_webvirtcloud-backups)`. `WVC_HEARTBEAT` is optional: a URL called after each good copy, such as a [healthchecks.io](https://healthchecks.io) check, which tells you when a day passes without one. ```bash install -m 600 /dev/null /etc/webvirtcloud-offsite.env cat > /etc/webvirtcloud-offsite.env <