# Migration from Wazuh 4.x to Wazuh 5: indices, agents and configuration

> Migrating from Wazuh 4.x to Wazuh 5.0-rc step by step: index snapshots, agent enrollment import, rewriting the manager and dashboard configuration.

Published: 2026-11-12. Category: Deployment. Tags: Wazuh 5. URL: https://wazuh.blog/en/blog/wazuh-5-migration-from-4x/ Polish original: https://wazuh.blog/blog/wazuh-5-migracja-z-4x/

A Wazuh 4.x environment cannot be upgraded in place to 5.x, so the migration means building a new deployment and moving into it what the documentation treats as portable. The sections below go component by component: indexer, manager, agents and dashboard.

The description is based on the 5.0-rc documentation (documentation.wazuh.com/5.0-rc), which is a release candidate: the pages carry a banner saying the release is under development, and names and settings may change. The full list of migration limitations, including the lack of frequency and threshold rules, is in [Wazuh 5 as a next-gen SIEM](/en/blog/wazuh-5-next-gen-siem/), and installing the new environment is covered in [Wazuh 5: installation](/en/blog/wazuh-5-installation/).

## Transition plan and prerequisites

The guide covers package, all-in-one and distributed deployments. The 4.x OVA virtual machine is an all-in-one installation, so the all-in-one steps apply to it. The guide does not cover Docker or Kubernetes, because the steps use package commands and host paths. The old environment stays running until validation is finished.

The documentation lists eight prerequisites:

1. A new 5.x environment with the same architecture, without reusing the 4.x deployment.
2. Version 4.4.0 or newer in the source, because indices can be restored only from it.
3. Network connectivity between the 4.x and 5.x environments.
4. A shared snapshot server, reachable from both indexer clusters and with enough capacity.
5. A backup of the 4.x deployment.
6. The 4.x manager stopped for the duration of the agent data export.
7. No agent enrolls in the 5.x manager, and 4.x agents stay with the 4.x manager until the enrollment import is done and verified.
8. A load balancer in front of the 5.x manager nodes, or a chosen node for each agent, before you upgrade the first agent.

A separate backup and restore page describes the indexer configuration backup: it covers certificates, `opensearch.yml`, the keystore and the security configuration, but not indexer data, and restore applies to the same version. Snapshots are used to move the data, so this backup protects the old cluster and is not meant for the migration to 5.x.

## Order of steps

The documentation imposes some dependencies, and I lay out the rest of the order as a recommendation:

| Step | Component | What you do | Dependency |
|------|-----------|-------------|------------|
| 1 | Both environments | 4.x backup, 5.x deployment, shared snapshot server | Prerequisites |
| 2 | Indexer 5.x | Recreate configuration and security | Files before start, `indexer-security-init.sh` after all nodes have started |
| 3 | Indexer | Snapshot on 4.x, read-only repository and restore on 5.x | Running 5.x cluster |
| 4 | Manager 5.x | Rewrite `wazuh-manager.conf` and validate | Recommendation: before the agents |
| 5 | Manager 4.x and 5.x | Export and import agent enrollments | 4.x manager stopped for the duration of the export |
| 6 | Dashboard 5.x | Configuration, saved objects | 5.x manager running |
| 7 | Agents | Change address, root CA certificate, package upgrade | Enrollment import verified |
| 8 | Manager host | Install an agent | After the enrollment import |

## Wazuh indexer: configuration and security

You do not copy the 4.x configuration to 5.x. You use it as a reference and recreate the settings by hand in the 5.x files on every node of the new cluster: `/etc/wazuh-indexer/opensearch.yml`, `jvm.options`, `log4j2.properties`, `certs/` and `opensearch-security/`. The documentation lists the settings that 5.x removes or changes:

| 4.x setting | Change in 5.x |
|-------------|---------------|
| `compatibility.override_main_response_version` | Removed, the indexer will not start with this entry |
| `cluster.initial_master_nodes` | Renamed to `cluster.initial_cluster_manager_nodes` |
| `plugins.security.ssl.transport.enforce_hostname_verification` | Moved to `transport.ssl.enforce_hostname_verification`, equal to `true` in 5.x |
| `plugins.security.authcz.admin_dn`, `plugins.security.nodes_dn` | Different DN attribute order, keep the values from the 5.x package |
| Settings of the anomaly detection, ML Commons, k-NN and similar plugins | Removed, because 5.x does not include these plugins |
| Multi-tenancy | Disabled by default |

Two traps: the indexer does not start when `opensearch.yml` defines both the old and the new name of the same setting, and with `enforce_hostname_verification: true` the certificate of every node must contain its address in the subject alternative names.

You export the active security configuration from a 4.x node, because the files on disk do not have to reflect it (the one in the security index applies):

```bash
# Run on a Wazuh 4.x indexer node
install -d -o wazuh-indexer -g wazuh-indexer /var/tmp/security-backup
/usr/share/wazuh-indexer/bin/indexer-security-init.sh --options "-backup /var/tmp/security-backup -icl -nhnv"
```

The exported `internal_users.yml`, `roles.yml` and `roles_mapping.yml` are a template to recreate from. In the index patterns inside roles, replace `wazuh-alerts-*` with `wazuh-events-v5-*`, `wazuh-findings-v5-*` and `wazuh-states-*`. A user with the old pattern can log in, but the dashboard will show them no data.

After restarting the service on every node, run `/usr/share/wazuh-indexer/bin/indexer-security-init.sh` once, from one node whose files contain all the changes. The script loads the files into the security index and may overwrite settings made earlier in the dashboard or through the API. Run from a node without the recreated users and roles, it removes them from the whole cluster, so the files in `opensearch-security/` must be identical on all nodes. Check external authentication backends, such as LDAP or SAML, on each node separately before you direct production traffic to it.

## Wazuh indexer: snapshots and restored indices

Data moves through snapshots, using a repository reachable from both clusters. The documentation shows a shared NFS directory `/mnt/snapshots`. On every node of both clusters you mount it, set the owner to `wazuh-indexer:wazuh-indexer` and add to `opensearch.yml`:

```yaml
path.repo:
  - /mnt/snapshots
```

After restarting the indexer, you create a Shared file system repository on 4.x (Indexer management > Snapshot Management > Repositories) and take a snapshot of the selected data indices. The documentation warns against including system indices or the cluster state: clear Include cluster state in snapshots. Note: an older page about index migration in the user manual lists this option as acceptable, but the 5.x migration guide takes precedence.

On the 5.x indexer you register the same repository as read-only, using the admin certificate:

```bash
curl -k -X PUT \
  --cert /etc/wazuh-indexer/certs/admin.pem \
  --key /etc/wazuh-indexer/certs/admin-key.pem \
  "https://192.0.2.10:9200/_snapshot/wazuh-4x-migration" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "fs",
    "settings": {
      "location": "/mnt/snapshots",
      "readonly": true
    }
  }'
```

The response is `{"acknowledged":true}`. You perform the restore in the 5.x dashboard (Snapshot Management > Snapshots > Restore), with the `restored_` prefix in the names. Do not restore system indices or the global cluster state, for example `.kibana*` and `.opendistro*`. To read the data you create an index pattern: in the name field type `restored_wazuh` (the dashboard appends `*`) and choose `timestamp` as the time field. The data appears in Discover.

What the restored indices give you: the data keeps its original timestamps and 4.x mappings, so it serves historical search. What they do not give you: Wazuh 5.x writes no new data to them, and they stay separate from the 5.x data streams. The fields are still named the old way, so you write queries against them in the 4.x schema. Indices created before 4.4.0 cannot be restored, even after a later upgrade.

## Wazuh manager: configuration and agent enrollments

The main file changed from `/var/ossec/etc/ossec.conf` to `/etc/wazuh-manager/wazuh-manager.conf` with the root `<wazuh_config>`. The file has a single root and each section appears once. The manager will not start if the file contains an unsupported option. The most important changes:

| 4.x section | Change in 5.x |
|-------------|---------------|
| `alerts`, `rule_test` | Removed or unsupported |
| `active-response`, `command` | Configuration on the Active Response page in the dashboard |
| `ruleset` | Custom rules, decoders and lists in content management |
| `rootcheck`, `syscheck`, `sca`, `localfile`, syscollector | Features moved to the agent |
| `global` | Only `agents_disconnection_time` |
| `cluster` | No `disabled`, requires a `key` different from the 4.x default |

You recreate custom rules according to [Wazuh 5: Sigma rules](/en/blog/wazuh-5-sigma-rules/). The rewritten file is checked by a command that points to the first unsupported option with its place in the file:

```bash
/var/wazuh-manager/bin/wazuh-manager-conf -f /etc/wazuh-manager/wazuh-manager.conf validate
```

The documentation adds three auxiliary files: `local_internal_options.conf` becomes `/etc/wazuh-manager/wazuh-manager-internal-options.conf`, `api.yaml` lives in `/var/wazuh-manager/api/configuration/api.yaml` (in a cluster only on the master node), and for `cluster.json` you take the 5.x file as a base and apply only the changed intervals.

### Agent enrollments

Two methods keep the agent IDs and keys. The `wazuh-migrate-identity.py` tool is simpler, but it does not keep enrollment dates (the date is the moment of import), it adds every agent to the default group and carries over only `agent.conf` from the groups. The manual procedure keeps the dates and the exact group membership. With the tool:

```bash
# On the Wazuh 4.x manager
curl -fsSLO https://raw.githubusercontent.com/wazuh/wazuh/5.0.0/tools/migration/wazuh-migrate-identity.py
chmod +x wazuh-migrate-identity.py
systemctl stop wazuh-manager
./wazuh-migrate-identity.py export --with-password --with-rbac --dry-run /root/wazuh-4x-bundle
./wazuh-migrate-identity.py export --with-password --with-rbac /root/wazuh-4x-bundle
systemctl start wazuh-manager
# Copy /root/wazuh-4x-bundle to the same path on the 5.x manager (scp)

# On the Wazuh 5.x manager
./wazuh-migrate-identity.py import --with-password --with-rbac --dry-run /root/wazuh-4x-bundle
./wazuh-migrate-identity.py import --with-password --with-rbac /root/wazuh-4x-bundle
./wazuh-migrate-identity.py check /root/wazuh-4x-bundle
```

A successful import ends with the message `The target matches the bundle.`. The `--with-rbac` option replaces the API users, roles and policies of the 5.x manager with the 4.x versions, including the passwords of `wazuh` and `wazuh-internal-client`. After the manager restarts, you must set both passwords back to the values from `/etc/wazuh-manager/export/credentials.env` with the `rbac_control change-password` command, otherwise the dashboard will not connect to the API. The bundle directory contains the agent keys, so delete it from both managers after validation.

In the manual procedure you stop the 4.x manager and copy `client.keys`, `global.db` and the group archive (without `shared/default`). On the 5.x manager you install the keys with `install -m 660 -o wazuh-manager -g wazuh-manager` into `/etc/wazuh-manager/client.keys`, and you copy the rows from the `agent`, `group` and `belongs` tables into the 5.x database through `sqlite3` (`ATTACH` of the old database and `INSERT OR REPLACE`), because the schema is different and you cannot swap the database file. The full SQL query is on the agents page. You check the state through the API:

```bash
TOKEN=$(curl -sk -u wazuh:PASSWORD -X POST "https://localhost:55000/security/user/authenticate?raw=true")
curl -sk "https://localhost:55000/agents?select=id,name,group,dateAdd" -H "Authorization: Bearer $TOKEN"
```

Agents have the status `never_connected` (tool) or `disconnected` (manual procedure) until they connect to the 5.x manager. The 5.x manager does not monitor its own host as agent 000, so install an agent there only after the import, so that its ID does not collide with the migrated one.

## Wazuh agents: address, certificate and upgrade

Changing the address is one edit of the agent's `ossec.conf` and a service restart (`systemctl restart wazuh-agent` on Linux):

```xml
<client>
  <server>
    <address>manager.example.com</address>
  </server>
</client>
```

A 4.x agent connected to a 5.x manager sends only log events and findings, so treat the upgrade to 5.x as part of the migration. A 5.x agent connects to a single manager address: if it had several `server` entries for failover in 4.x, after the upgrade it uses the last one. So leave one entry, pointing to the load balancer or a specific node. According to the 5.0-rc architecture description, the 5.x agent talks to the manager over HTTPS on port 1517/TCP, and the manager keeps ports 1514 and 1515 for 4.x agents.

The 5.x agent verifies the manager's certificate, and the package upgrade does not install the root CA certificate, so before it, on Linux, copy it from `/etc/wazuh-manager/certs/root-ca.pem` on the manager:

```bash
mkdir -p /var/ossec/etc/certs
install -m 640 -o root -g wazuh root-ca.pem /var/ossec/etc/certs/root-ca.pem
dpkg -i --force-confold wazuh-agent_VERSION_amd64.deb
grep "TLS verification" /var/ossec/logs/ossec.log
```

With the `--force-confold` flag the upgrade does not stop at the configuration file question. If an earlier `dpkg -i` stopped at that question, finish it with `dpkg --configure --force-confold wazuh-agent`, because running `dpkg -i` again overwrites the agent's key and configuration. The last command in the block should not return a message about disabled TLS verification. If the agent was upgraded without the certificate, stop it and run `/var/ossec/bin/wazuh-agent-auth --token-file TOKEN_FILE --certs-only` with a token generated on the 5.x manager (Agents management > Enrollment tokens > Create token). A new 4.x agent enrolls on port 1515 with the enrollment password of the 5.x manager from `/etc/wazuh-manager/authd.pass`, set in the `WAZUH_REGISTRATION_PASSWORD` variable. 4.x agent enrollment is covered in [agent enrollment](/en/blog/wazuh-agent-enrollment/), and 5.x tokens in [Wazuh 5 installation](/en/blog/wazuh-5-installation/).

## Wazuh dashboard: what you recreate

You deploy the 5.x dashboard from scratch. You move the configuration from `/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml` to `/etc/wazuh-dashboard/opensearch_dashboards.yml`, and the connection to the manager API looks like this:

```yaml
wazuh_core.hosts:
  default:
    url: https://192.0.2.20
    port: 55000
    username: wazuh-internal-client
    run_as: true
```

The user `wazuh-internal-client` replaces `wazuh-wui`, and you do not put the password in the file, because the dashboard reads it from the keystore. Take the port and `run_as` from the 4.x deployment (55000 is an example value). You recreate the advanced settings (`timeout`, `enrollment.dns`, `reports.csv.maxRows`, `wazuh.updates.disabled`) in Dashboards Management > Advanced Settings, and you check the connection in Health Check. The `cron.*` and `wazuh.monitoring.*` settings are gone, and branding is configured by `opensearchDashboards.branding.*`. PDF reports and report branding cannot be recreated.

You move only your own saved objects (dashboards, visualizations, saved searches, index patterns), never the default 4.x dashboards, because they would overwrite the default 5.x objects. On export, turn off Include related objects, otherwise the `wazuh-alerts-*` pattern goes along with them. On import, choose Check for existing objects and Request action on conflict, and resolve the `wazuh-alerts-*` pattern conflict by choosing a 5.x pattern, for example `wazuh-findings-v5*`. With multitenancy enabled, you export and import separately for each tenant.

Fields in queries must be rewritten to WCS:

| 4.x field | 5.x field | Note |
|-----------|-----------|------|
| `rule.level` | `wazuh.rule.level` | Values `low`, `medium`, `high`, `critical`, `informational` instead of 0-16 |
| `rule.description` | `wazuh.rule.title` | Rule title |
| `rule.id` | `wazuh.rule.id` | IDs are UUIDs, filters on 4.x numbers do not match |
| `agent.name` | `wazuh.agent.name` | Agent name |
| `agent.id` | `wazuh.agent.id` | Agent ID |
| `rule.groups` | `wazuh.integration.name` | Source integration |

You rewrite the query `rule.level >= 5` as `wazuh.rule.level:(medium or high or critical)`.

## What the documentation does not specify

The documentation does not say which 4.x versions the agent enrollment migration supports (it only mentions indices from 4.4.0), whether the default 5.x dashboards show the restored `restored_*` indices, or which index pattern to use in roles for those indices. It also gives no time estimates and no snapshot capacity estimates.

## Sources

- https://documentation.wazuh.com/5.0-rc/migration-to-5x/index.html
- https://documentation.wazuh.com/5.0-rc/migration-to-5x/transition-plan.html
- https://documentation.wazuh.com/5.0-rc/migration-to-5x/wazuh-indexer.html
- https://documentation.wazuh.com/5.0-rc/migration-to-5x/wazuh-manager.html
- https://documentation.wazuh.com/5.0-rc/migration-to-5x/wazuh-agents.html
- https://documentation.wazuh.com/5.0-rc/migration-to-5x/wazuh-dashboard.html
- https://documentation.wazuh.com/5.0-rc/user-manual/wazuh-indexer/migrating-wazuh-indices.html
- https://documentation.wazuh.com/5.0-rc/user-manual/wazuh-indexer/backup-and-restore.html
- https://documentation.wazuh.com/5.0-rc/getting-started/architecture.html
