Upgrade and backup
Upgrade by hand with upgrade.sh, drain before upgrading, roll back automatically on failure, use online updates and offline import, understand automatic rule updates and the false-positive safety valve, and protect the control plane with upgrade backups, cold standby and hot standby.
An upgrade only replaces images and deployment files. .env, data/ and the data volumes are kept, the host fingerprint does not change, and the licence does not need to be activated again.
Upgrade by hand
Point the installed upgrade.sh at the directory of the new package. The new package is then verified with the installed public key before any of its code runs:
tar -xf rstwaf-<new-version>-linux-amd64.tar
sudo /opt/rstwaf/upgrade.sh /path/to/rstwaf-<new-version>-linux-amd64The upgrade runs these steps:
- Verify the signature. A package whose serial is not higher than the installed one is refused; add
--allow-downgradeto force a downgrade. - Run preflight checks and load the new images.
- Drain, as described below.
- Stop the services and back up
.env, configuration,data/, the database and the CrowdSec and other volumes to/opt/rstwaf/backups/<time>-<old-version>/. Services are stopped during the backup, usually for less than a minute. - Replace the files and start the services. The control plane runs database migrations on start.
- Run health checks. Both the data plane and the control plane must report the new version and pass 3 checks in a row.
If any step fails, the upgrade rolls back on its own: it restores every file and volume, starts the old images and checks health again. The last 3 backups are kept. Old images are also kept; remove them when prompted once you are satisfied.
In a multi-node deployment, upgrade the control plane first, then each node with the same command.
Draining before an upgrade
Before stopping services, upgrade.sh puts the local data plane into a draining state. Each site's GET /.rstwaf/healthz returns 503 with the header X-RSTWAF-Draining: 1, while application requests are still served. It waits --drain-seconds seconds (15 by default) for the load balancer to remove the node, stops the data plane and allows up to 30 more seconds for in-flight requests. The new version starts without the draining state, and the load balancer adds the node back once health checks pass.
- The load balancer's check interval multiplied by its failure threshold must be shorter than the drain time. With the default 15 seconds, a 5-second interval and 2 failures works.
- On a single host with no load balancer, draining only adds 15 seconds. Add
--drain-seconds 0to skip it. - Draining applies from 1.0.3 onwards. Upgrades from 1.0.2 or earlier do not drain, and the older installed
upgrade.shdoes not know--drain-seconds; if needed, use the environment variable instead:sudo RSTWAF_DRAIN_SECONDS=0 /opt/rstwaf/upgrade.sh <package directory>.
Online updates
Turn online updates on under Settings > Online updates (在线更新); they are off by default. The update source is a set of static files with a signed manifest, either the vendor channel or an internal mirror you host.
- In offline mode (
RSTWAF_ONLINE_FEATURES=off) only an internal mirror is reachable. To use the vendor channel, tick Allow internet update source on the same page. This opens the update source only, keeps every other outbound connection closed, and is recorded in the audit log. - Rules and threat intelligence are fetched on a schedule (every 24 hours by default) or with Check now (立即检查), and applied automatically by default. Rule bundles that an administrator has disabled or rolled back are not reinstalled automatically. In a multi-node deployment they reach nodes through configuration snapshots.
- Software is only announced, never installed on its own. After an administrator downloads it, chooses to upgrade and confirms by typing the version number,
update-runner.shon the host runs the installedupgrade.sh, with the same signature check, backup, health checks and rollback. With several nodes, the control plane upgrades first and the nodes follow one at a time. A failed node pauses the rollout, which you can retry, skip or stop. - Permission: upgrading needs the Upgrade software version (升级软件版本) permission, which super administrators have by default. It can only be done from a console session, never with an API token.
- Licensing: rule bundles are free; virtual patches need the corresponding licence. With a licence you can upgrade to versions released before your maintenance end date. After maintenance expires, the current version keeps running.
On hosts without systemd, or installed with --no-update-runner, run this by hand after confirming the upgrade in the console:
sudo /opt/rstwaf/update-runner.sh runVersion 1.0.0 does not yet have the Allow internet update source option. To move from 1.0.0 to the vendor channel, set RSTWAF_ONLINE_FEATURES=on in .env, run docker compose up -d, then turn on online updates in the console and upgrade. Afterwards you can set RSTWAF_ONLINE_FEATURES back to off and tick Allow internet update source instead.
Offline import
The vendor packs the same manifest and packages into a .rstu file. Upload it with Offline import (离线导入) on the online updates page, or copy it to /opt/rstwaf/updates/inbox/, which the control plane scans every minute; results appear in the update history. Signature checks, rollback protection and rule activation work as for online updates. Software packages in the file arrive as downloaded, and upgrading still needs confirmation in the console.
False-positive safety valve
Rule and threat-intelligence bundles applied automatically enter an observation window of 30 minutes by default, adjustable in the settings. If any of the following happens within the window, from at least 3 source IPs, the bundle rolls back to the previous version and a system alert is raised (规则更新已自动回滚):
- Likely false positives (blocks with no attack signature) from the new rules reach 1% or more of requests.
- The block rate reaches 3 times the baseline, mainly because of the new rules.
- The new rules match 5 or more times at locations that are already allowed.
A rolled-back version is not reinstalled automatically. An administrator chooses to keep the rollback or apply the version again.
Backup
Every upgrade writes a backup to /opt/rstwaf/backups/ and keeps the last 3. For continuous protection, use the control plane cold standby.
What to back up:
| Item | Notes |
|---|---|
/opt/rstwaf/.env | Its RSTWAF_MASTER_KEY encrypts TOTP and alert-channel secrets in the database, which cannot be decrypted without it |
| Control plane database and file state | Configuration, accounts, events, audit log, certificates and private keys, rule bundles, tamper-protection baselines, reports |
nodes/ in the control plane volume | Node CA and snapshot signing key. If lost, every node must join again |
Control plane cold standby
The cold standby continuously replicates the control plane database and all file state to a target you own. The database is synchronised every second and files are checked for changes every 10 seconds. If the host fails, one command on a standby host takes over. No public cloud service is involved.
# Choose one: a second local disk or NFS directory, SFTP, or self-hosted S3-compatible storage
sudo /opt/rstwaf/cp-backup.sh enable --file /mnt/standby/rstwaf-cp
sudo /opt/rstwaf/cp-backup.sh enable --sftp [email protected]:22:/srv/rstwaf-cp --sftp-key /root/.ssh/rstwaf_backup \
--sftp-host-key 'ecdsa-sha2-nistp256 AAAA…'
sudo RSTWAF_CPBACKUP_S3_KEY_ID=… RSTWAF_CPBACKUP_S3_SECRET=… /opt/rstwaf/cp-backup.sh enable --s3 https://minio.lan:9000/rstwaf/cp
sudo /opt/rstwaf/cp-backup.sh status # replication state and the last restore drill
sudo /opt/rstwaf/cp-backup.sh verify # run a drill now: restore to a temporary directory and check it, leaving the live database alone
sudo /opt/rstwaf/cp-backup.sh disable # stop replicatingA restore drill runs 5 minutes after enabling and daily after that. If replication fails, falls more than 5 minutes behind or a drill fails, Control plane cold standby (控制面冷备) at the bottom of Sites and nodes > Nodes shows the problem and a system alert is raised (控制面备份异常).
Preparing the standby: install the same version on the standby host, but first copy the primary's /opt/rstwaf/.env to the same path on the standby over a trusted channel (mode 0600). The address nodes use to reach the control plane must be able to move to the standby, either a VIP (keepalived, which you provide) or a DNS name with a TTL of 30 to 60 seconds.
Taking over: confirm the primary is stopped or isolated and the address now points at the standby, then run takeover on the standby with the same target options used when enabling:
sudo RSTWAF_CPBACKUP_S3_KEY_ID=… RSTWAF_CPBACKUP_S3_SECRET=… /opt/rstwaf/cp-backup.sh takeover --yes --s3 https://minio.lan:9000/rstwaf/cpIf the old primary still answers on the node address, the script refuses to take over. Nodes usually reconnect and sync within a minute. Manual bans made in the console are not replicated and must be applied again. Once the new primary is stable, run cp-backup.sh enable again with a new target path.
Control plane hot standby
Building on the cold standby, a hot standby follows the replica continuously. With a third small host acting as witness (cp-witness.sh), a primary that loses its lease isolates itself and the standby takes over within seconds. Without a witness, takeover is manual: run cp-backup.sh ha-promote --yes on the standby. A recovered primary becomes the standby of the new primary and does not take the role back.
Open ports 9447 (witness) and 9448 (between the two control planes) on the management network between the three hosts. A standby more than 30 seconds behind does not take over automatically. cp-backup.sh ha-status shows the role, term, witness and replication lag, as does Control plane hot standby (控制面热备) under Sites and nodes > Nodes. Contact support for the hot standby setup procedure.
Licence and restore
- Restoring from backup, or rolling back from the cold standby, on the same host keeps the host fingerprint.
- Moving to a different host changes the fingerprint, and Reallysec must issue the licence again.
- Reinstalling with the data volumes cleared also changes the fingerprint, and a new licence must be requested.
Sign-in and third-party sign-in
Console account sign-in, one-time codes and sign-in security settings, setting up Feishu or Lark QR sign-in, and the single exception for offline deployments.
Console tour
Signing in to the console, the sidebar groups and menus, pages shown by permission, and what the overview page contains.