Перейти к содержимому

Backup & restore

OkYouIn backs up its configuration into encrypted archives — on a schedule and on demand. An archive is everything you would need to rebuild the server as it was configured: users, factors, applications, policies, settings, keys and certificates. Restoring is done from the server’s command line, on the same server (to undo a change) or on a new one (when the old one is gone).

Every archive is encrypted with the installation’s master key, secrets/master_key in the installation directory, and does not contain it.

Never edit or replace the master key of a running installation: a new key cannot open the secrets already in the database.

In the archive (configuration)Not in the archive (history and runtime data)
users, groups, administrator rolesthe Access log, audit log and every sign-in journal
MFA enrolments (TOTP, Web Push devices, Telegram)RADIUS sessions, alerts
applications, their rules, RADIUS secrets, custom dictionariesconsole and SSO sessions, pending challenges
Windows agent hosts and their break-glass codesGeoIP databases (downloaded and uploaded)
policies, network objects, time ranges, country listsIP blocks, manual ones included
syslog destinations, e-mail templatesthe AD machine account (domain join)
the console’s HTTPS certificate, OIDC signing keys, SAML certificates
every setting: SMTP, LDAP, Telegram, GeoIP source, backup schedule…
the license, installation ID and trial dates

Scheduled backups are on by default: every 24 hours, the last 5 kept. Change the interval and the number kept on Settings ▸ System ▸ Backup & Recovery under Schedule & Retention. The same page lists the archives, can Create backup now, and Download any archive. Each archive shows whether the running master key opens it (current key).

Archives are stored in a Docker volume on the server itself. Copy them off the host regularly — a backup that lives only on the server it protects is lost with it.

From the installation directory:

Terminal window
./okyouin backup # create one archive now
./okyouin backup list # archives, newest first; "current key" = this key opens it
./okyouin backup export okyouin-backup-<UTC>.tar /some/dir # copy one out of the volume

backup export writes the archive with mode 600. A script that runs ./okyouin backup and then backup export to a mounted share is a simple way to keep copies off the host.

Use this to undo a bad change. From the installation directory:

Terminal window
./okyouin restore okyouin-backup-<UTC>.tar

The argument is a name from backup list, or a file on the server. The restore:

  1. checks that this installation’s master key opens the archive — before any downtime;
  2. stops the application, shows the archive’s version and asks you to type yes;
  3. writes a safety backup of the current state (restoring that one undoes the restore);
  4. loads the archive, starts the application and restarts the RADIUS and domain services.
OptionEffect
--yesno question; required when there is no terminal
--no-backupno safety backup of the current state
--forcerestore an archive from another version — dangerous, avoid it

The load is a single database transaction: if anything fails, nothing changes. Exit codes 2 (another key), 3 (another version or schema) and 4 (not confirmed) also mean nothing was changed.

What happens to the rest:

  • The configuration is replaced: anything configured after the archive was made is gone.
  • History stays: the audit log, Access log and journals on this server are kept.
  • Live state ends: every console session, pending MFA challenges, unused enrolment links and SSO sessions. Users sign in again; a VPN user passes MFA again on the next connection.

When the old server is gone:

  1. Install the same version. The archive’s version and database schema must match. Install OkYouIn of the archive’s version, with the saved master key:

    Terminal window
    OKYOUIN_MASTER_KEY_FILE=/path/to/master_key ./install.sh --images <image archive>
  2. Restore the archive. There is nothing on the new server to keep:

    Terminal window
    ./okyouin restore /path/to/okyouin-backup-<UTC>.tar --no-backup
  3. Sign in with an account from the archive.

  4. Redo what is not in the archive:

    • join the AD domain again if you use MS-CHAPv2 (the LDAP configuration’s Domain tab);
    • GeoIP databases come back with their daily download, or at once with Update now on Settings ▸ Integrations ▸ GeoIP; uploaded .mmdb files must be uploaded again;
    • IP blocks start empty: re-enter manual blocks under Logging ▸ Blocked IPs.

Keep the same public URL as before: Web Push devices and passkeys are bound to it, and the OIDC and SAML applications know the server by it. With another address users must enroll their Web Push device again.

The license, installation ID and trial dates are in the archive, so the license stays valid on the new server — see Licensing & trial.

On a high-availability cluster:

  • The scheduled backup runs on the current leader and lands in that node’s volume; after a failover archives are spread across nodes. A manual backup runs on any node that reaches the primary. Copy archives off every node.
  • A node cut off from the primary takes no backup and no restore.
  • A restore runs on the leader only, and only while every database node streams from it. Find the leader with ./okyouin cluster status, copy the archive there (./okyouin backup export on the node that holds it), and run ./okyouin restore on the leader. Before anything stops it checks the cluster and refuses with the reason: exit 6 (not the leader — it names the leader), 5 (no writable primary) or 7 (a node not streaming; --allow-degraded goes on knowingly). The other nodes take the restored data by replication.
  • Each archive made on a cluster node also carries the cluster’s certificate authority, sealed under the master key. If the alert Backup without the etcd CA appears, run ./okyouin seal-etcd-ca and then ./okyouin backup on that node.