# System services: update, backup, restore, rollback Day-2 operations. Every update takes a verified backup first and rolls back automatically on failure. Install: [System services](README.md). ## Update ```sh deploy/native/update.sh # run from the checkout with the new version deploy/native/update.sh --ui-dist /root/ui-dist.tar.gz # install this UI (tarball or directory), always deploy/native/update.sh --build-ui # build the UI from APP_UI on this host and install it deploy/native/update.sh --source /root/ovpmon-src --yes # another checkout, no questions deploy/native/update.sh --no-pull # sources already in place / offline deploy/native/update.sh --rollback # manual rollback to the newest backup ``` Run it from the checkout that holds the new version (the script uses the templates of that checkout). `--prefix` and the HTTPS port come from `/etc/ovpmon/deploy.state`. The update needs access to PyPI for the new virtualenvs. Each phase is logged separately: | Phase | What happens | If it fails | |---|---|---| | 0 Preflight | installation present, no unfinished install, source checkout complete, an explicit UI source readable (`--build-ui`: builder usable), services state, databases found, free space (backup and new code) | nothing was changed | | 1 **Backup** | verified backup in `/var/backups/ovpmon//` (see below) | the update is **refused**, nothing was changed | | 2 Sources | `git pull --ff-only` of the source checkout (skipped with `--no-pull` or without git) | nothing was changed | | 3 Prepare | new code copied to `.new`, fresh virtualenvs with `pip install -r requirements.txt`, import check; the UI source is decided (after `git pull`: `--ui-dist`, `--build-ui`, the committed build; unchanged hash means no swap) and the new UI is staged next to the web root. **The running system is not touched** | nothing was changed | | 4 Stop and swap | the three application services are stopped (**OpenVPN keeps running**, VPN users stay connected); a final consistent snapshot; each code directory is renamed to `.old-