SaaS-10-2026 3.6 3.5 3.4 AgileSec On-Prem AgileSec SaaS
SaaS-10-2026 3.6 3.5 3.4 AgileSec On-Prem AgileSec SaaS

On-Prem Backup and Disaster Recovery Process Guide

This guide outlines disaster recovery and backup procedures for the On-Prem AgileSec Linux installations. To minimize downtime, this guide provides guidelines for backing up your data and reconstituting the AgileSec Platform from a previous backup in the event of a catastrophic failure.

1. Overview

The platform keeps data in two datastores and depends on an identity (certificates and keys) every service was installed with. A backup captures all three. A recovery restore rebuilds the identity first, by installing the target cluster with the source cluster's identity bundle, then loads the data.

1.1 Guide Scenario Conditions

This guide provides backup and disaster recovery instructions with the following conditions:

Supported

Not supported by this guide

Disaster recovery onto a new target cluster after the source cluster is lost.

Restoring onto the same cluster the backup came from.

Source and target on exactly the same AgileSec release version.

Restoring onto a different AgileSec release (upgrade or downgrade during recovery).

Backups stored in AWS S3.

Restoring from a shared file system (NFS) backup.

Note: The restore steps in this guide read from S3 only.

Info: This guide was validated with a three-node cluster (two backend nodes, one frontend node).

1.2 Guide Definitions

The following terms are used throughout this guide.

Term

Meaning

Source cluster

AgileSec cluster backups were taken from. In a disaster recovery and restore scenario this cluster no longer exists.

Target cluster

A new AgileSec cluster, on new VMs, source cluster backups are restored onto.

Identity bundle

Tarball the installer generates, <analytics_internal_domain>-certs.tgz.

The identity bundle holds

  • cluster's root CA, certificates and keys

  • Secrets Manager (SM) keystore

  • SAML material

  • the Kafka cluster ID

  • one .env file per node

Pre-seeded install

Installing the target cluster with the source cluster's identity bundle and .env files already in place, allowing the target cluster to take on the source cluster's identity during installation.


2. Guide Prerequisite: Set Backup and Recovery Variables

Set these in every shell session you use for a backup AND recovery steps. Replace the placeholders with your own values.

Directory Path Variables

There are two referenced directory locations in these instructions:

  1. installer_dir: the location where the unzipped install files reside, including all installation scripts and supporting files.

  2. agilesec_install_dir: the location where AgileSec will be installed to.

Export these as bash variables to easily copy and paste guide instructions:

export installer_dir=</path/to/installer>
export agilesec_install_dir=</path/to/installation>

Paths Info: To identify the correct paths, look for the following:

  • agilesec_install_dir (the deployed installation) contains .env file(s)

  • installer_dir (the unpacked installer package) contains scripts/.vars instead

Bash
# Paths
export agilesec_install_dir=</path/to/installation>   # the deployed installation
export installer_dir=</path/to/installer>             # the unpacked installer package

# Domains (defaults shown; use your cluster's values)
export analytics_internal_domain="kf-agilesec.internal"
export org_domain="kf-agilesec.com"
export analytics_hostname="agilesec"

# This node's internal FQDN, for example backend-1.kf-agilesec.internal.
# Use the FQDN, not 127.0.0.1 or an IP address: the certificates only
# name the FQDN, so TLS verification fails against an IP.
export NODE_FQDN="<node-name>.$analytics_internal_domain"

# Admin client certificate used for OpenSearch and MongoDB
export CA_CERT="$agilesec_install_dir/certificates/ca/agilesec-rootca-cert.pem"
export CLIENT_CERT="$agilesec_install_dir/certificates/$analytics_internal_domain/admin-user-cert.pem"
export CLIENT_KEY="$agilesec_install_dir/certificates/$analytics_internal_domain/admin-user-key.pem"
export OS_URL="https://$NODE_FQDN:9200"

# Backup location
export S3_BUCKET="<backup-bucket>"
export S3_REGION="<bucket-region>"        # for example us-east-1
export BACKUP_PREFIX="<environment-name>" # one prefix per environment

# Shorthand for authenticated OpenSearch calls
oscurl() { curl -s --cacert "$CA_CERT" --cert "$CLIENT_CERT" --key "$CLIENT_KEY" "$@"; }

3. Backup the Source Cluster

In order to recover from disaster, it is crucial to have a robust backup strategy including the following considerations:

  1. Recovery point objective (RPO). Decide how much data loss is acceptable based on data criticality and your organizational policies, then set backup frequency and retention to match.

  2. Keep backups off the cluster. Backups MUST NOT live on the same disk or VM as the data they protect. Store them in object storage (such as AWS S3) or on a separate disaster recovery site.

  3. Check every run. Backup scripts should check each command's exit code and confirm backup files exist and are not empty.

  4. Practice the restore (drill testing). Run a test restore onto a non-production target cluster every quarter to verify data integrity.

The following items should be backed up to enable cluster recovery in case of disaster.

Backup item

Contains

Backup Method

Backup Location (S3)

1

Identity bundle

Root CA, certificates and keys, SM keystore, SAML material, Kafka cluster ID, per-node .env files, and the public-facing $analytics_hostname.$org_domain certificate

Generated by the installer and copied by you.

s3://$S3_BUCKET/$BACKUP_PREFIX/identity-bundle/

2

OpenSearch snapshot

Scan-finding indices (agilesec.*) and the org tenant's saved dashboards (.kibana_*_*_*)

OpenSearch Snapshot API.

The snapshot repository at s3://$S3_BUCKET/$BACKUP_PREFIX/

3

OpenSearch security config

Roles, role mappings, internal users, tenants, and the rest of the security plugin's configuration

AgileSec Security Admin Script securityadmin.sh -backup

s3://$S3_BUCKET/$BACKUP_PREFIX/opensearch-security/<stamp>/

4

MongoDB dump

Operational data: configuration state, platform settings, policies, scan history

MongoDB dump command mongodump --oplog

s3://$S3_BUCKET/$BACKUP_PREFIX/mongodb/

Important: Use one timestamp for all four items of a backup run so a restore can pick a matching set:

Bash
export STAMP=$(date -u +%Y%m%dt%H%M%Sz)   # for example 20260917t192034z

The OpenSearch snapshot is named $STAMP, and the other three items carry $STAMP in their file or folder names.

Backup 1: Identity Bundle

The installer generates the identity bundle once, on the node where certificates are first generated, and places an identical copy on every other node during installation. Back it up from any one node:

Bash
BUNDLE="$installer_dir/certificates/${analytics_internal_domain}-certs.tgz"
tar -tzf "$BUNDLE"    # confirm it is readable; lists ca/, the domain folders, and env.<node> files
aws s3 cp "$BUNDLE" \
  "s3://$S3_BUCKET/$BACKUP_PREFIX/identity-bundle/${STAMP}-${analytics_internal_domain}-certs.tgz"

The bundle contains the root CA's private key. Restrict access to the backup location accordingly.

Warning: If OpenSearch uses static AWS keys in opensearch.keystore, those keys are not in the bundle or in any snapshot, because the keystore is local to each node. When restoring, the static AWS keys must be added again on the target cluster to match the source cluster.

Backup 2: OpenSearch

OpenSearch snapshots are the only supported way to back up OpenSearch data.

2.1 Set up the snapshot repository (once)

Register a snapshot repository before the first backup. The restore steps in this guide read from S3.

The repository must be reachable from every OpenSearch node, including nodes with only the cluster-manager role. If even one node lacks the S3 plugin, registration fails with the error repository type [s3] does not exist.

  1. Install repository-s3 plugin on every OpenSearch node. On each OpenSearch node, one node at a time, install the repository-s3 plugin and restart OpenSearch on the node. --batch accepts the plugin's permission prompt, which otherwise waits for input.

    Bash
    cd "$agilesec_install_dir/services/opensearch/bin"
    sudo ./opensearch-plugin install --batch repository-s3
    cd "$agilesec_install_dir" && ./scripts/manage.sh restart opensearch
    

    Wait until the cluster reports green before moving to the next node:

    Bash
    oscurl "$OS_URL/_cluster/health?pretty" | grep -E '"status"|"number_of_nodes"'
    
  2. Credentials.

    1. If the nodes run with an IAM instance profile that can reach the bucket, skip this step, the plugin uses the IAM instance profile automatically.

    2. Otherwise, add static keys on every node:

      Bash
      cd "$agilesec_install_dir/services/opensearch/bin"
      ./opensearch-keystore add s3.client.default.access_key
      ./opensearch-keystore add s3.client.default.secret_key
      
  3. Bucket access. Grant least-privilege access to the bucket only:

    JSON
    {
      "Version": "2012-10-17",
      "Statement": [{
        "Sid": "AgileSecBackups",
        "Effect": "Allow",
        "Action": ["s3:PutObject", "s3:GetObject", "s3:DeleteObject", "s3:ListBucket", "s3:GetBucketLocation"],
        "Resource": ["arn:aws:s3:::<backup-bucket>", "arn:aws:s3:::<backup-bucket>/*"]
      }]
    }
    
  4. Register the repository as backup, with $BACKUP_PREFIX as its base path:

    Bash
    oscurl -X PUT "$OS_URL/_snapshot/backup" -H 'Content-Type: application/json' \
      -d "{\"type\":\"s3\",\"settings\":{\"region\":\"$S3_REGION\",\"bucket\":\"$S3_BUCKET\",\"base_path\":\"$BACKUP_PREFIX\"}}"
    
  5. Verify every node can reach the snapshot repository. Run the following command on every node:

    Bash
    oscurl -X POST "$OS_URL/_snapshot/backup/_verify?pretty"
    

    The response lists every node in the cluster. A repository_verification_exception that mentions S3 AccessDenied means the bucket policy from step 3 is missing or not attached to the nodes' role.

The S3 layout for one environment then looks like this:

Path under s3://$S3_BUCKET/$BACKUP_PREFIX/

Contents

index-*, index.latest, indices/, meta-*.dat, snap-*.dat

OpenSearch snapshot repository files (managed by OpenSearch)

identity-bundle/<stamp>-<domain>-certs.tgz

Identity bundle

opensearch-security/<stamp>/

Security config backup

mongodb/mongo-<stamp>.tar.gz

MongoDB dump

2.2 Take a snapshot

From backend-1 take an OpenSearch snapshot:

Bash
oscurl -X PUT "$OS_URL/_snapshot/backup/$STAMP?wait_for_completion=true" \
  -H 'Content-Type: application/json' \
  -d '{"indices":"-.opendistro_security,agilesec.*,.kibana_*_*_*,-.kibana*admintenant*","ignore_unavailable":true,"include_global_state":false}'

The index list includes the scan-finding indices and every tenant's saved objects. Two indices are left out of the snapshot on purpose.

Pattern

Included

Why

agilesec.*

Yes

Scan findings.

.kibana_*_*_*

Yes

Each tenant's dashboards, visualizations, and saved searches.

.opendistro_security

No

The security plugin's live index.

This index’s content is backed up separately with the OpenSearch security config.

.kibana*admintenant*

No

The admin tenant index holds built-in demo content.

Save dashboards you want backed up under your org tenant.

Note: If you use v2 sensors, or upgraded from AgileSec 3.4 or earlier, some data may still sit in isg.* indices. Add isg.* to the index list in that case.

When the snapshot finishes, wait_for_completion=true makes the call return. Confirm the result:

Bash
oscurl "$OS_URL/_snapshot/backup/$STAMP?pretty" | grep -E '"state"|"total"|"successful"|"failed"'

Expect result is "state" : "SUCCESS" and failed equal to 0.

Backup 3: OpenSearch Security Config

On backend-1, run securityadmin.sh -backup without -t to capture all ten configuration types:

Bash
export OS_BACKUP_DIR="$HOME/backups/opensearch-security/$STAMP"
mkdir -p "$OS_BACKUP_DIR"
export OPENSEARCH_JAVA_HOME="$agilesec_install_dir/bin/java"
"$agilesec_install_dir/services/opensearch/plugins/opensearch-security/tools/securityadmin.sh" \
  -h "$NODE_FQDN" -p 9200 -backup "$OS_BACKUP_DIR" -icl -nhnv \
  -cacert "$CA_CERT" -cert "$CLIENT_CERT" -key "$CLIENT_KEY"

For S3, upload the result:

Bash
aws s3 cp --recursive "$OS_BACKUP_DIR/" "s3://$S3_BUCKET/$BACKUP_PREFIX/opensearch-security/$STAMP/"

Backup 4: MongoDB

Run mongodump against the primary or a secondary mongodb node. --oplog makes the dump consistent to a single point in time across the replica set.

Important: --oplog only works on a full dump, so do not combine with --db or --collection.

Bash
export MDB_BACKUP_DIR="$HOME/backups/mongo/$STAMP"
mkdir -p "$MDB_BACKUP_DIR"
CLIENT_PEM="$(mktemp)"; chmod 600 "$CLIENT_PEM"
cat "$CLIENT_CERT" "$CLIENT_KEY" > "$CLIENT_PEM"

"$agilesec_install_dir/bin/mongodb-tools/bin/mongodump" \
  --uri "mongodb://$NODE_FQDN:27017" --oplog --out "$MDB_BACKUP_DIR" \
  --ssl --sslCAFile "$CA_CERT" --sslPEMKeyFile "$CLIENT_PEM" \
  --authenticationMechanism MONGODB-X509
rm -f "$CLIENT_PEM"

tar -czf "/tmp/mongo-$STAMP.tar.gz" -C "$(dirname "$MDB_BACKUP_DIR")" "$STAMP"
aws s3 cp "/tmp/mongo-$STAMP.tar.gz" "s3://$S3_BUCKET/$BACKUP_PREFIX/mongodb/mongo-$STAMP.tar.gz"
rm -f "/tmp/mongo-$STAMP.tar.gz"

4. Disaster Recovery: Restore Target Cluster

Restoring after disaster recovery has five stages. The stage order matters. The target cluster has to carry the source cluster's identity before any data is restored. The restored data and the services reading the data in the target cluster expect the identity to match the source cluster’s.

Prerequisite: Recovery Requirements

The following must match between target cluster and the source cluster before proceeding with restoration:

Requirement

Why

1

Fresh VMs with no AgileSec installation yet.

The pre-seeded install in Stage 1 is the target's first and only installation.

2

AWS CLI with read access to the backup bucket on every node.

Every restore stage downloads from S3.

3

Exactly the same AgileSec release.

Restoring across different releases is not supported by this guide.

4

Same analytics_hostname, org_domain, and analytics_internal_domain.

The certificates in the identity bundle name these domains.

5

Same number of nodes, with the same node names and roles (for example backend-1, backend-2, frontend-1).

The bundle holds one .env file per source node, keyed by node name.

Pick one backup set and confirm all prerequisite items exist for the backup set’s stamp:

Bash
aws s3 ls "s3://$S3_BUCKET/$BACKUP_PREFIX/identity-bundle/"
aws s3 ls "s3://$S3_BUCKET/$BACKUP_PREFIX/opensearch-security/"
aws s3 ls "s3://$S3_BUCKET/$BACKUP_PREFIX/mongodb/"
export STAMP="<stamp of the chosen backup set>"   # for example 20260917t192034z

The OpenSearch snapshot for the same stamp is checked in Stage 2 once the repository is registered on the target.

Reminder: If OpenSearch uses static AWS keys in opensearch.keystore, those keys are not in the backed up identity bundle or in any snapshot, because the keystore is local to each node. When restoring, the static AWS keys must be added again on the target cluster to match the source cluster.

Stage 1: Restore Identity Bundle and Install Identical Target Cluster

Install the target cluster pre-seeded with the source cluster's certificates and .env files, so every service is built from the source cluster's identity.

  1. Download and extract the identity bundle from the S3 backup:

    Bash
    mkdir -p "$HOME/restore-identity-bundle"
    aws s3 cp "s3://$S3_BUCKET/$BACKUP_PREFIX/identity-bundle/${STAMP}-${analytics_internal_domain}-certs.tgz" \
      "$HOME/restore-identity-bundle/"
    cd "$HOME/restore-identity-bundle"
    tar -xzf "${STAMP}-${analytics_internal_domain}-certs.tgz"
    ls   # Expected result: ca/  $analytics_internal_domain/  $analytics_hostname.$org_domain/  env.<node> files
    
  2. Copy the three certificate folders from the identity bundle into the installer:

    Bash
    cp -r "$analytics_hostname.$org_domain" ca "$analytics_internal_domain" "$installer_dir/certificates/"
    
  3. On each node, copy each node's respective .env file from the bundle to $installer_dir/.env. For example, on backend-1:

    Bash
    cp env.backend-1 "$installer_dir/.env"
    
  4. On each node, edit $installer_dir/.env and change only the IP address fields to the target cluster's IPs:

Field

Change to

private_ip

This node's IP address

cluster_backend_nodes_ip

The backend nodes' IPs, one per line, in the same order as cluster_backend_nodes

cluster_frontend_nodes_ip

The frontend nodes' IPs, in the same order as cluster_frontend_nodes

cluster_coordinator_nodes_ip

The coordinator nodes' IPs, if you have any, in the same order as cluster_coordinator_nodes

Leave every other field .env exactly as is. Several fields, including the SM key aliases, opensearch_exchange_key, platform_init_org_saml_id, and webui_nextauth_secret, are unique to the source cluster's installation. The restored data depends on them.

  1. From installer_dir, tune the node, and then run the install script. Replace <install-user> with the Linux user who owns the installation (for example, ec2-user):

    Bash
    cd "$installer_dir"
    sudo ./scripts/tune.sh -u <install-user>
    ./install_analytics.sh install -u <install-user> -p "$agilesec_install_dir" --non-interactive
    

Warning: Do NOT run ./generate_envs/generate_envs.sh or generate_certs.sh on the target cluster. These will cause the target cluster to generate its own identity instead of using the source cluster's.

  1. Repeat steps 1 to 5 on every node.

Stage 2: Restore OpenSearch

Run these steps from backend-1 unless a step says otherwise.

  1. Install the S3 plugin on every OpenSearch node, one node at a time. A new installation does not have the S3 plugin by default. (These instructions are identical to setting up the snapshot repository during backup procedures.)

    1. On each OpenSearch node, one node at a time, install the repository-s3 plugin and restart OpenSearch on the node. --batch accepts the plugin's permission prompt, which otherwise waits for input:

      Bash
      cd "$agilesec_install_dir/services/opensearch/bin"
      sudo ./opensearch-plugin install --batch repository-s3
      cd "$agilesec_install_dir" && ./scripts/manage.sh restart opensearch
      
    2. Wait until the cluster reports green before moving to the next node:

      Bash
      oscurl "$OS_URL/_cluster/health?pretty" | grep -E '"status"|"number_of_nodes"'
      
  2. Register the backup repository with the same bucket, region, and base path the backup used. The snapshots are already in S3; the target cluster only needs to know where to find them.

    1. Run the following command to register the backup repository:

      Bash
      oscurl -X PUT "$OS_URL/_snapshot/backup" -H 'Content-Type: application/json' \
        -d "{\"type\":\"s3\",\"settings\":{\"region\":\"$S3_REGION\",\"bucket\":\"$S3_BUCKET\",\"base_path\":\"$BACKUP_PREFIX\"}}"
      
    2. {"acknowledged":true} only means the request was well formed. The next step confirms the settings are correct.

  3. Check the repository and the snapshot.

    1. Run the following commands to check the repository and snapshot:

      Bash
      oscurl "$OS_URL/_snapshot/_all?pretty"                   # the "backup" repository is listed
      oscurl -X POST "$OS_URL/_snapshot/backup/_verify?pretty" # every node is listed
      oscurl "$OS_URL/_cat/snapshots/backup?v"                 # $STAMP is listed with status SUCCESS
      
    2. If $STAMP is missing, the bucket, region, or base path does not match the backup. Register the repository again with the right values.

  4. Delete empty indices for restore replacement. A new installation creates empty scan-finding indices and fills the org tenant with default dashboards. The restore API refuses to overwrite an existing index, even if empty, so these empty indices must be deleted before restoration.

Pattern

Action

Why

1

agilesec.*

Delete

Empty on a new installation; the snapshot recreates them.

2

.kibana_*_*_*

Delete

Default dashboard content; the snapshot replaces them.

3

.opendistro_security

Keep

The security plugin needs it. Step 6 restores its content.

4

.kibana*admintenant*

Keep

Demo content local to this installation.

    1. List the empty indices to delete, then delete them:

      Bash
      TARGET="agilesec.*,.kibana_*_*_*,-.opendistro_security,-.kibana*admintenant*"
      oscurl "$OS_URL/_cat/indices/$TARGET?v&s=index&h=index,health,docs.count"
      oscurl -X DELETE "$OS_URL/$TARGET"
      

Warning: Run step 5 to restore the snapshot immediately after this step, and keep everyone out of OpenSearch Dashboards in between. Opening Dashboards recreates the tenant's .kibana index, and the restore then fails with the message an open index with same name already exists in the cluster. If this error happens, run the delete again and restore immediately.

  1. Restore the snapshot.

    1. Run the following to restore the snapshot:

      Bash
      oscurl -X POST "$OS_URL/_snapshot/backup/$STAMP/_restore?wait_for_completion=true" \
        -H 'Content-Type: application/json' \
        -d '{"indices":"agilesec.*,.kibana_*_*_*,-.opendistro_security,-.kibana*admintenant*","ignore_unavailable":true,"include_global_state":false}'
      
      1. ignore_unavailable is required. The two excluded patterns name indices not in the snapshot. If you added isg.* to the backup, add it here, too.

    2. The response should show "failed":0.

    3. Wait for the cluster to finish building replicas, then check the restored indices:

      Bash
      oscurl "$OS_URL/_cluster/health?wait_for_status=green&timeout=120s&pretty" | grep '"status"'
      oscurl "$OS_URL/_cat/indices/agilesec.*,.kibana_*_*_*?v&s=index&h=index,health,docs.count"
      
    4. Indices can show yellow for a short time after the restore while replicas are built. However, every index should end up green after snapshot restoration.

  2. Restore the security config.

    1. Download the backup for the same stamp, then apply roles, tenants, role mappings, and internal users:

      Bash
      export OS_BACKUP_DIR="$HOME/restore-security-config/$STAMP"
      mkdir -p "$OS_BACKUP_DIR"
      aws s3 cp --recursive "s3://$S3_BUCKET/$BACKUP_PREFIX/opensearch-security/$STAMP/" "$OS_BACKUP_DIR/"
      
      export OPENSEARCH_JAVA_HOME="$agilesec_install_dir/bin/java"
      for pair in roles:roles.yml tenants:tenants.yml rolesmapping:roles_mapping.yml internalusers:internal_users.yml; do
        "$agilesec_install_dir/services/opensearch/plugins/opensearch-security/tools/securityadmin.sh" \
          -h "$NODE_FQDN" -p 9200 -icl -nhnv -t "${pair%%:*}" -f "$OS_BACKUP_DIR/${pair#*:}" \
          -cacert "$CA_CERT" -cert "$CLIENT_CERT" -key "$CLIENT_KEY"
      done
      
    2. Each run ends with Done with success. The backup also holds the other six configuration types, including config.yml (SSO and LDAP settings). This procedure does not restore them.

Stage 3: Restore MongoDB

  1. Stop the services writing to MongoDB. MongoDB itself keeps running. --disable-healthcheck comments out the scripts/health_check.sh cron entry, which would restart the stopped services while the restore is running.

    Bash
    cd "$agilesec_install_dir"
    ./scripts/manage.sh stop --disable-healthcheck analytics-manager ingestion indexing scheduler sm   # on each backend node
    ./scripts/manage.sh stop --disable-healthcheck api webui cbom                                       # on the frontend node
    
  2. Find the primary. Run the restore against the replica set's primary:

    Bash
    CLIENT_PEM="$(mktemp)"; chmod 600 "$CLIENT_PEM"
    cat "$CLIENT_CERT" "$CLIENT_KEY" > "$CLIENT_PEM"
    "$agilesec_install_dir/bin/mongosh" "mongodb://$NODE_FQDN:27017" --quiet \
      --tls --tlsCAFile "$CA_CERT" --tlsCertificateKeyFile "$CLIENT_PEM" \
      --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 \
      --eval 'rs.status().members.forEach(m => print(m.name, m.stateStr))'
    export MONGO_URI="mongodb://<primary node FQDN>:27017"
    
  3. Download and extract the dump from S3:

    Bash
    mkdir -p "$HOME/restore-mongo"
    aws s3 cp "s3://$S3_BUCKET/$BACKUP_PREFIX/mongodb/mongo-$STAMP.tar.gz" "$HOME/restore-mongo/"
    tar -xzf "$HOME/restore-mongo/mongo-$STAMP.tar.gz" -C "$HOME/restore-mongo"
    ls "$HOME/restore-mongo/$STAMP"   # one folder per database, plus oplog.bson
    
  4. Restore the MongoDB dump:

    Bash
    "$agilesec_install_dir/bin/mongodb-tools/bin/mongorestore" \
      --uri "$MONGO_URI" --drop --nsExclude='admin.*' \
      --ssl --sslCAFile "$CA_CERT" --sslPEMKeyFile "$CLIENT_PEM" \
      --authenticationMechanism MONGODB-X509 \
      "$HOME/restore-mongo/$STAMP"
    

Flag

Why

--drop

Drops each collection before restoring, so the result matches the backup.

--nsExclude='admin.*'

Leaves the admin database alone.

Restoring admin.system.users would recreate the user the restore connection is signed in as, ending the session, and every later step would fail with Command createIndexes requires authentication.

Do not use --oplogReplay

mongorestore does not allow --oplogReplay together with --nsExclude. The only data this skips is what changed while the dump was running.

  1. Verify failed count is 0. The last line of the output reads <N> document(s) restored successfully. <N> document(s) failed to restore. Confirm the failed count is 0.

  2. Check the replica set, with the same mongosh command as step 2:

    1. Bash
      CLIENT_PEM="$(mktemp)"; chmod 600 "$CLIENT_PEM"
      cat "$CLIENT_CERT" "$CLIENT_KEY" > "$CLIENT_PEM"
      "$agilesec_install_dir/bin/mongosh" "mongodb://$NODE_FQDN:27017" --quiet \
        --tls --tlsCAFile "$CA_CERT" --tlsCertificateKeyFile "$CLIENT_PEM" \
        --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 \
        --eval 'rs.status().members.forEach(m => print(m.name, m.stateStr))'
      export MONGO_URI="mongodb://<primary node FQDN>:27017"
      
    2. Every member should report PRIMARY, SECONDARY, or ARBITER.

    3. After checking, remove the client PEM:

      Bash
      rm -f "$CLIENT_PEM"
      

Stage 4: Restart every service

  1. Restart all services on every node, one node at a time, backend nodes first:

    Bash
    cd "$agilesec_install_dir"
    ./scripts/manage.sh restart
    ./scripts/manage.sh status
    
  2. Wait until status shows every service running before moving to the next node. This one restart covers everything the restore touched, including services holding long-lived MongoDB, Kafka, or TLS connections.

  3. If the health check cron was enabled before the restore, turn it back on by restarting with --enable-healthcheck instead:

    Bash
    ./scripts/manage.sh restart --enable-healthcheck
    

Important: Over a non-interactive SSH session, manage.sh restart keeps the service in the foreground and does not return. In this case, run the service restart detached:

setsid nohup ./scripts/manage.sh restart > /tmp/restart.log 2>&1 < /dev/null &

Stage 5: Verify Recovery

  1. Check the identity on every node

    1. Ensure agilesec_install_dir, analytics_internal_domain, analytics_hostname, and org_domain variables are set correctly.

    2. restore_checklist.sh (Appendix B) compares each node against the source cluster's identity bundle. This script only reads and changes nothing. Run restore_checklist.sh on every node:

      Bash
      export source_identity_bundle="$HOME/restore-identity-bundle/${STAMP}-${analytics_internal_domain}-certs.tgz"
      ./restore_checklist.sh
      
    3. The expected result on every node is:

      == All checks passed. ==
      
    4. Checks not applicable to a node are reported as [SKIP]. The exit code is 0 when every check passes and 1 otherwise. Passwords in the output are redacted unless you add --show-secrets. Appendix A lists what each check covers.

  2. Check the platform. Perform the following checks to verify the restored cluster is working as expected:

Check

Expected result

What the check confirms

Sign in to the application

Sign-in works and you stay signed in

Identity: SM keystore, JWT signing, public certificate

Open the Overview Dashboard

The source cluster's scan data is shown

OpenSearch restore

Open Scan History

The source cluster's scans are listed

MongoDB restore

Open Advanced Dashboard

The OpenSearch Advanced Dashboard opens without an error

SAML single sign-on into OpenSearch Dashboards

Run a network scan

The network scan completes

Scheduler, ingestion, and scan worker trust and tokens

Recovery Troubleshooting

If any verification checks fail, troubleshoot with the following:

Symptom

Likely cause

What to do

1

opensearch-plugin install waits and never finishes

The install command is waiting for the permission prompt

Add --batch

2

Repository registration fails with repository type [s3] does not exist

One OpenSearch node is missing repository-s3

Install the s3 plugin on every node, including cluster-manager-only nodes (Stage 2 step 1)

3

Restore fails with repository_missing_exception or $STAMP is not listed

Repository not registered, or repository registered with a different bucket, region, or base path

Stage 2 steps 2 and 3

4

Restore fails with an open index with same name already exists in the cluster

Someone opened Dashboards between the delete and the restore

Delete again and restore immediately (Stage 2, steps 4 and 5)

5

mongorestore fails with Command createIndexes requires authentication

admin.* was not excluded

Re-run with --nsExclude='admin.*'

6

restore_checklist.sh reports certificates/ does not match the source identity bundle

The bundle's certificate folders were not copied into installer_dir/certificates/ before installing, or generate_envs.sh ran

Reinstall the node as described in Stage 1

7

restore_checklist.sh fails on keystore passwords, certificates, or public keys

The node was installed with its own identity (not the source cluster’s) or with a .env from a different cluster

Reinstall the node as described in Stage 1

8

Sign-in fails in browser with unable to verify the first certificate

The $analytics_hostname.$org_domain folder was not copied from the identity bundle

Reinstall the node as described in Stage 1

9

A service fails right after the restore with MongoDB, Kafka or TLS errors

The service was not restarted

Stage 4

Note: If the checks pass but a scan still fails, the scan worker's own log under logs/scanWorker/ usually declares why. This log is deleted when the job ends, unless APP_SCAN_SCHEDULER_PROFILE_WORKER_WORKDIR_DELETE and APP_SCAN_SCHEDULER_SENSOR_WORKER_WORKDIR_DELETE in config_envs/scheduler are set to false.

Set both variables to false, restart scheduler, run the scan again, and read the log. After reading the log and troubleshooting, set these variables back to true.


Appendices

Appendix A: Where the Cluster Identity is Copied

During installation, several services make their own copy of identity material from the certificates, keystore, and .env values, and never read the originals again. A pre-seeded install builds every copy from the source cluster's identity. A target cluster installed with its own identity would have every one of them wrong, and replacing certificates/ afterward would not fix them. This is why Restore Stage 1 installs the target with the source cluster's bundle.

9a53005af88ea8c41e105a7287959a909bb84a239964280c9b54e268c0ebe775.png

Identity copy

Location(s)

Symptom when target identity does not match

Service(s) to restart after correcting

Checked by restore_checklist.sh

1

SM keystore password and key aliases

Nodes running sm service:

config_envs/sm.properties

Sign-in succeeds, then you are signed out; API calls return 401

sm

Yes (check 1)

2

OpenSearch TLS certificate files

Every node:

services/opensearch-*/config/certs/ on every node

Node-to-node SSL errors (PKIX path validation failed) in agilesec-cluster.log

opensearch

Yes (check 2)

3

JWT signing alias and public key for api and cbom

Frontend nodes:

  • config_envs/api (JWT_CMK_ALIAS, PUBLIC_KEY)

  • config_envs/cbom (JWT_CMK_ALIAS, JWT_PUBLIC_KEY)

Sign-in succeeds, then API calls return 401

api, cbom

Public key only (check 3). The alias must match the source cluster's .env.

4

SAML IdP metadata

Frontend nodes:

services/opensearch-*/config/opensearch-security/idp-metadata.xml

Advanced Dashboard fails with failed to get token; OpenSearch logs Signature verification failed

opensearch

Yes (check 4)

5

SAML signing passphrase

Frontend nodes:

config_envs/api (SAML_PASSPHRASE)

/v1/saml/verify-user returns 500 with bad decrypt

api

Yes (check 4)

6

SAML signing private key

Frontend nodes:

services/api/dist/modules/v1/saml/config/privatekey.pem

/v1/saml/verify-user returns 500 with bad decrypt

api

Yes (check 4)

7

MongoDB TLS keystore password for scheduler and analytics-manager

Backend nodes and frontend-1:

  • bin/scheduler_entrypoint.sh

  • bin/analytics_manager_entrypoint.sh

  • config_envs/scheduler (SCAN_WORKER_OPTION)

Scans do not run; logs show Unable to create default SSLContext and keystore password was incorrect

scheduler, analytics-manager

Yes (check 5)

8

Root CA in the JVM trust store

Every node:

bin/java/lib/security/cacerts, alias root.<analytics_internal_domain>

Scans do not run; logs show PKIX path validation failed: Path does not chain with any of the trust anchors

scheduler, analytics-manager

Yes (check 6)

9

JWT signing alias and public key for ingestion

Backend nodes:

config_envs/ingestion (APP_SMTOKENKEYPAIRALIAS, APP_TOKENPUBLICKEY)

ingestion.log shows validation of jwt token signature failed

ingestion

Yes; public key only (check 7). The alias must match the source cluster's .env.

10

JWT signing alias for scheduler and analytics-manager

Backend nodes:

  • config_envs/scheduler (APP_SCAN_SCHEDULER_SM_TOKEN_KEYPAIR)

  • config_envs/analytics-manager (APP_SMTOKENKEYPAIRALIAS)

sm.log shows tokens for scheduler signed with an alias from a different cluster

scheduler, analytics-manager

No. The alias must match the source cluster's .env.

11

Root CA in the OS trust store

Every node:

/etc/pki/ca-trust/source/anchors/agilesec-rootca-cert.pem

Scans stay queued; the scan worker log shows x509: certificate signed by unknown authority

None; the scan worker reads it on every run

Yes (check 8)

12

Public-facing HAProxy certificate

Frontend nodes:

certificates/$analytics_hostname.$org_domain/agilesec-analytics-server-combo-cert-key.pem

Browser sign-in fails with unable to verify the first certificate, while service logs stay clean

haproxy (needs sudo)

Yes (check 9)

Appendix B: restore_checklist.sh

Save the script on every node as restore_checklist.sh and make it executable (chmod +x restore_checklist.sh).

restore_checklist.sh
Bash
#!/usr/bin/env bash
# Read-only check that this node carries the expected cluster identity.
# It compares the install-time copies of identity material (Appendix A of
# the guide) against either the source cluster's identity bundle or this
# node's own certificates/. It never changes anything on the node.
#
# Usage:
#   ./restore_checklist.sh                  # redacts passwords in the output
#   ./restore_checklist.sh --show-secrets   # prints compared passwords in full
#
# Exit code: 0 if every check passes, 1 if any check fails, 2 on bad input.
set -euo pipefail

: "${agilesec_install_dir:?export agilesec_install_dir first}"
: "${analytics_internal_domain:?export analytics_internal_domain first}"

SHOW_SECRETS="false"
for arg in "$@"; do
  case "$arg" in
    --show-secrets) SHOW_SECRETS="true" ;;
    *) echo "Unknown argument: $arg" >&2; exit 2 ;;
  esac
done

CERTS_DIR="$agilesec_install_dir/certificates/$analytics_internal_domain"
CA_CERT="$agilesec_install_dir/certificates/ca/agilesec-rootca-cert.pem"
KEYTOOL="$agilesec_install_dir/bin/java/bin/keytool"
# The installer names the root CA root.<analytics_internal_domain>, both
# as its CN (which names the OS trust store's extracted file) and as its
# alias in the JVM's cacerts.
ROOT_CA_NAME="root.$analytics_internal_domain"
FAILURES=0

pass() { echo "  [PASS] $1"; }
fail() { echo "  [FAIL] $1"; FAILURES=$((FAILURES + 1)); }
skip() { echo "  [SKIP] $1 (not present on this node)"; }
redact() { if [[ "$SHOW_SECRETS" == "true" ]]; then echo "$1"; else echo "<redacted, pass --show-secrets to reveal>"; fi; }

# Reads VAR="...multi-line PEM with real newlines..." (ingestion's format,
# distinct from api's and cbom's single-quoted escaped-\n format).
read_dquoted_pem_var() {
  local file="$1" var="$2"
  KEY_FILE="$file" VAR_NAME="$var" python3 - <<'PYEOF'
import os, re
p = os.environ["KEY_FILE"]; var = os.environ["VAR_NAME"]
s = open(p).read()
m = re.search(var + r'="(.*?)"', s, re.DOTALL)
print(m.group(1) if m else "")
PYEOF
}

echo "== Restore checklist (read-only) =="

# ---------- Identity source ----------
# With source_identity_bundle set to a local copy of the source cluster's
# <analytics_internal_domain>-certs.tgz, every check compares this node
# against that bundle, extracted to a temporary directory. Without it,
# every check compares this node against its own certificates/, which
# catches drift inside one cluster but says nothing about which cluster's
# identity the node carries.
EXPECTED_CERTS_DIR="$CERTS_DIR"
EXPECTED_CA_CERT="$CA_CERT"
EXPECTED_SRC_LABEL="this node's own certificates/"
BUNDLE_TMP=""

if [[ -n "${source_identity_bundle:-}" ]]; then
  [[ -f "$source_identity_bundle" ]] || { echo "source_identity_bundle not found: $source_identity_bundle" >&2; exit 2; }

  echo
  echo "-- Identity bundle vs certificates/ --"
  BUNDLE_TMP=$(mktemp -d)
  trap 'rm -rf "$BUNDLE_TMP"' EXIT
  tar -xzf "$source_identity_bundle" -C "$BUNDLE_TMP"

  # saml_id.pass is created by the install itself and is not in the
  # bundle; its presence alone is not drift.
  BUNDLE_DIFF=$( { diff -rq "$BUNDLE_TMP/ca" "$agilesec_install_dir/certificates/ca" 2>&1; \
                   diff -rq -x saml_id.pass "$BUNDLE_TMP/$analytics_internal_domain" "$CERTS_DIR" 2>&1; } || true )
  if [[ -n "$BUNDLE_DIFF" ]]; then
    fail "certificates/ does not match the source identity bundle"
    echo "$BUNDLE_DIFF" | sed 's/^/    /'
  else
    pass "certificates/ matches the source identity bundle"
  fi

  EXPECTED_CERTS_DIR="$BUNDLE_TMP/$analytics_internal_domain"
  EXPECTED_CA_CERT="$BUNDLE_TMP/ca/agilesec-rootca-cert.pem"
  EXPECTED_SRC_LABEL="the source identity bundle ($source_identity_bundle)"
else
  echo
  echo "-- Identity bundle vs certificates/ --"
  echo "  [SKIP] source_identity_bundle not set; comparing against this node's own certificates/"
fi

EXPECTED_SM_P12="$EXPECTED_CERTS_DIR/sm-service.p12"
EXPECTED_SM_PASS_FILE="$EXPECTED_CERTS_DIR/sm-service-keystore.pass"

# ---------- SM keystore aliases and password ----------
# Read from the expected identity, not from any one service's config, so
# checks 1, 3 and 7 work on whichever of their files exist on this node.
KP_ALIAS=""
CMK_ALIAS=""
SM_PASS=""
if [[ -f "$EXPECTED_SM_P12" && -f "$EXPECTED_SM_PASS_FILE" ]]; then
  SM_PASS=$(cat "$EXPECTED_SM_PASS_FILE")
  KEYTOOL_OUT=$("$KEYTOOL" -list -v -keystore "$EXPECTED_SM_P12" -storetype PKCS12 -storepass "$SM_PASS")
  KP_ALIAS=$(awk '/Alias name/{a=$3} /Entry type: PrivateKeyEntry/{print a; exit}' <<< "$KEYTOOL_OUT")
  CMK_ALIAS=$(awk '/Alias name/{a=$3} /Entry type: SecretKeyEntry/{print a; exit}' <<< "$KEYTOOL_OUT")
fi
KP_ALIAS_SRC="PrivateKeyEntry alias in sm-service.p12 ($EXPECTED_SRC_LABEL)"
CMK_ALIAS_SRC="SecretKeyEntry alias in sm-service.p12 ($EXPECTED_SRC_LABEL)"
EXPECTED_PUBLIC_KEY=""
if [[ -n "$KP_ALIAS" ]]; then
  EXPECTED_PUBLIC_KEY=$("$KEYTOOL" -exportcert -rfc -alias "$KP_ALIAS" -keystore "$EXPECTED_SM_P12" \
    -storetype PKCS12 -storepass "$SM_PASS" | openssl x509 -pubkey -noout)
fi

# ---------- 1. SM keystore password and aliases ----------
echo
echo "[1/9] SM keystore (sm.properties)"
SM_PROPERTIES="$agilesec_install_dir/config_envs/sm.properties"
if [[ -f "$SM_PROPERTIES" && -n "$KP_ALIAS" ]]; then
  CUR_PASS=$(grep '^keystore.password=' "$SM_PROPERTIES" | cut -d= -f2-)
  CUR_CMK=$(grep '^keystore.cmkAlias=' "$SM_PROPERTIES" | cut -d= -f2-)
  CUR_KP=$(grep '^keystore.kpAlias=' "$SM_PROPERTIES" | cut -d= -f2-)
  if [[ "$CUR_PASS" != "$SM_PASS" ]]; then
    fail "keystore.password mismatch. current=$(redact "$CUR_PASS") expected=$(redact "$SM_PASS") ($EXPECTED_SRC_LABEL)"
  else
    pass "keystore.password matches"
  fi
  if [[ "$CUR_CMK" != "$CMK_ALIAS" ]]; then
    fail "keystore.cmkAlias=$CUR_CMK, expected $CMK_ALIAS ($CMK_ALIAS_SRC)"
  else
    pass "keystore.cmkAlias matches ($CMK_ALIAS)"
  fi
  if [[ "$CUR_KP" != "$KP_ALIAS" ]]; then
    fail "keystore.kpAlias=$CUR_KP, expected $KP_ALIAS ($KP_ALIAS_SRC)"
  else
    pass "keystore.kpAlias matches ($KP_ALIAS)"
  fi
else
  skip "sm.properties (or sm-service.p12 not found in $EXPECTED_SRC_LABEL)"
fi

# ---------- 2. OpenSearch's own certificate copy ----------
echo
echo "[2/9] OpenSearch's certificate copy"
FOUND_OS_CONF="false"
for OS_CONF in "$agilesec_install_dir"/services/opensearch-*/config; do
  [[ -d "$OS_CONF/certs" ]] || continue
  FOUND_OS_CONF="true"
  REL="${OS_CONF#$agilesec_install_dir/}"
  for pair in "$EXPECTED_CERTS_DIR/agilesec-internal-server-cert.pem:agilesec-internal-server-cert.pem" \
              "$EXPECTED_CERTS_DIR/agilesec-internal-server-key.pem:agilesec-internal-server-key.pem" \
              "$EXPECTED_CA_CERT:agilesec-rootca-cert.pem"; do
    src="${pair%%:*}"; f="${pair##*:}"
    SRC_SUM=$(sha256sum "$src" | awk '{print $1}')
    DST_SUM=$(sha256sum "$OS_CONF/certs/$f" 2>/dev/null | awk '{print $1}' || echo "missing")
    if [[ "$SRC_SUM" != "$DST_SUM" ]]; then
      fail "$REL/certs/$f: sha256 $DST_SUM, expected $SRC_SUM ($EXPECTED_SRC_LABEL)"
    else
      pass "$REL/certs/$f matches ($SRC_SUM)"
    fi
  done
done
[[ "$FOUND_OS_CONF" == "false" ]] && skip "services/opensearch-*/config/certs"

# ---------- 3. JWT public key (api, cbom) ----------
# Only the public key is compared. The alias fields are not: a working
# install writes them from the SM CMK alias, not the keypair alias, and
# the only valid rule for them is "same as the source cluster's .env".
echo
echo "[3/9] JWT public key (api, cbom)"
if [[ -n "$EXPECTED_PUBLIC_KEY" ]]; then
  for spec in "api:PUBLIC_KEY" "cbom:JWT_PUBLIC_KEY"; do
    svc="${spec%%:*}"; var="${spec##*:}"
    ENV_FILE="$agilesec_install_dir/config_envs/$svc"
    if [[ -f "$ENV_FILE" ]]; then
      CUR_KEY=$(grep "^$var=" "$ENV_FILE" | sed "s/^$var='//;s/'$//" | sed 's/\\n/\n/g')
      if [[ "$CUR_KEY" != "$EXPECTED_PUBLIC_KEY" ]]; then
        fail "config_envs/$svc $var does not match the public key exported from alias '$KP_ALIAS' ($KP_ALIAS_SRC)"
        echo "    current:"; echo "$CUR_KEY" | sed 's/^/      /'
        echo "    expected:"; echo "$EXPECTED_PUBLIC_KEY" | sed 's/^/      /'
      else
        pass "config_envs/$svc $var matches (exported from alias '$KP_ALIAS', $KP_ALIAS_SRC)"
      fi
    else
      skip "config_envs/$svc"
    fi
  done
else
  skip "JWT public key (sm-service.p12 not found in $EXPECTED_SRC_LABEL)"
fi

# ---------- 4. SAML material for Advanced Dashboard ----------
echo
echo "[4/9] SAML material for Advanced Dashboard"
IDP_CERT_B64=$(grep -v "BEGIN CERTIFICATE\|END CERTIFICATE" "$EXPECTED_CERTS_DIR/idp-cert.pem" | tr -d '\n')
FOUND_IDP_META="false"
for OS_SEC in "$agilesec_install_dir"/services/opensearch-*/config/opensearch-security; do
  [[ -f "$OS_SEC/idp-metadata.xml" ]] || continue
  FOUND_IDP_META="true"
  REL="${OS_SEC#$agilesec_install_dir/}"
  CUR_CERT=$(grep -o '<ds:X509Certificate>.*</ds:X509Certificate>' "$OS_SEC/idp-metadata.xml" | sed 's/<[^>]*>//g')
  if [[ "$CUR_CERT" != "$IDP_CERT_B64" ]]; then
    fail "$REL/idp-metadata.xml certificate does not match idp-cert.pem ($EXPECTED_SRC_LABEL)"
  else
    pass "$REL/idp-metadata.xml certificate matches idp-cert.pem"
  fi
done
[[ "$FOUND_IDP_META" == "false" ]] && skip "opensearch-security/idp-metadata.xml"

API_ENV="$agilesec_install_dir/config_envs/api"
if [[ -f "$API_ENV" ]]; then
  SAML_PASS=$(cat "$EXPECTED_CERTS_DIR/saml.pass")
  CUR_SAML_PASS=$(grep '^SAML_PASSPHRASE=' "$API_ENV" | cut -d= -f2- | tr -d '"')
  if [[ "$CUR_SAML_PASS" != "$SAML_PASS" ]]; then
    fail "config_envs/api SAML_PASSPHRASE mismatch. current=$(redact "$CUR_SAML_PASS") expected=$(redact "$SAML_PASS") ($EXPECTED_SRC_LABEL)"
  else
    pass "config_envs/api SAML_PASSPHRASE matches"
  fi
else
  skip "config_envs/api (SAML_PASSPHRASE)"
fi

API_SAML_KEY="$agilesec_install_dir/services/api/dist/modules/v1/saml/config/privatekey.pem"
if [[ -f "$API_SAML_KEY" ]]; then
  SRC_SUM=$(sha256sum "$EXPECTED_CERTS_DIR/idp-enc-key.pem" | awk '{print $1}')
  DST_SUM=$(sha256sum "$API_SAML_KEY" | awk '{print $1}')
  if [[ "$SRC_SUM" != "$DST_SUM" ]]; then
    fail "services/api/dist/.../privatekey.pem: sha256 $DST_SUM, expected $SRC_SUM (idp-enc-key.pem, $EXPECTED_SRC_LABEL)"
  else
    pass "services/api/dist/.../privatekey.pem matches idp-enc-key.pem ($SRC_SUM)"
  fi
else
  skip "services/api/dist/modules/v1/saml/config/privatekey.pem"
fi

# ---------- 5. scheduler/analytics-manager MongoDB TLS keystore password ----------
echo
echo "[5/9] scheduler/analytics-manager MongoDB TLS keystore password"
SHARED_CLIENT_PASS_FILE="$EXPECTED_CERTS_DIR/agilesec-client-keystore.pass"
if [[ -f "$SHARED_CLIENT_PASS_FILE" ]]; then
  SHARED_CLIENT_PASS=$(cat "$SHARED_CLIENT_PASS_FILE")
  for spec in "bin/scheduler_entrypoint.sh:bin/scheduler_entrypoint.sh keyStorePassword" \
              "bin/analytics_manager_entrypoint.sh:bin/analytics_manager_entrypoint.sh keyStorePassword" \
              "config_envs/scheduler:config_envs/scheduler SCAN_WORKER_OPTION keyStorePassword"; do
    rel="${spec%%:*}"; label="${spec#*:}"
    FILE="$agilesec_install_dir/$rel"
    if [[ -f "$FILE" ]]; then
      CUR_PASS=$(sed -n 's/.*keyStorePassword="\?\([^"\\ ]*\)"\?.*/\1/p' "$FILE" | head -1)
      if [[ "$CUR_PASS" != "$SHARED_CLIENT_PASS" ]]; then
        fail "$label mismatch. current=$(redact "$CUR_PASS") expected=$(redact "$SHARED_CLIENT_PASS") ($EXPECTED_SRC_LABEL)"
      else
        pass "$label matches"
      fi
    else
      skip "$rel"
    fi
  done
else
  skip "scheduler/analytics-manager MongoDB TLS keystore password (agilesec-client-keystore.pass not found in $EXPECTED_SRC_LABEL)"
fi

# ---------- 6. JVM default truststore (cacerts) CA entry ----------
echo
echo "[6/9] JVM default truststore (cacerts) CA entry"
CACERTS="$agilesec_install_dir/bin/java/lib/security/cacerts"
if [[ -f "$CACERTS" ]]; then
  EXPECTED_CA_FP=$(openssl x509 -in "$EXPECTED_CA_CERT" -noout -fingerprint -sha256 | cut -d= -f2)
  CUR_CA_FP=$("$KEYTOOL" -list -v -keystore "$CACERTS" -storepass changeit -alias "$ROOT_CA_NAME" 2>/dev/null \
    | awk -F'SHA256: ' '/SHA256:/{print $2; exit}')
  if [[ -z "$CUR_CA_FP" ]]; then
    fail "cacerts has no alias '$ROOT_CA_NAME'; expected it to hold the CA from $EXPECTED_SRC_LABEL"
  elif [[ "$CUR_CA_FP" != "$EXPECTED_CA_FP" ]]; then
    fail "cacerts alias '$ROOT_CA_NAME' fingerprint $CUR_CA_FP, expected $EXPECTED_CA_FP ($EXPECTED_SRC_LABEL)"
  else
    pass "cacerts alias '$ROOT_CA_NAME' fingerprint matches ($CUR_CA_FP)"
  fi
else
  skip "bin/java/lib/security/cacerts"
fi

# ---------- 7. ingestion JWT public key ----------
# Only ingestion's public key is compared. The alias fields in
# scheduler, ingestion and analytics-manager are not checked, for the
# same reason as check 3.
echo
echo "[7/9] ingestion JWT public key"
if [[ -n "$EXPECTED_PUBLIC_KEY" ]]; then
  INGESTION_ENV="$agilesec_install_dir/config_envs/ingestion"
  if [[ -f "$INGESTION_ENV" ]]; then
    CUR_KEY=$(read_dquoted_pem_var "$INGESTION_ENV" "APP_TOKENPUBLICKEY")
    if [[ "$CUR_KEY" != "$EXPECTED_PUBLIC_KEY" ]]; then
      fail "config_envs/ingestion APP_TOKENPUBLICKEY does not match the public key exported from alias '$KP_ALIAS' ($KP_ALIAS_SRC)"
      echo "    current:"; echo "$CUR_KEY" | sed 's/^/      /'
      echo "    expected:"; echo "$EXPECTED_PUBLIC_KEY" | sed 's/^/      /'
    else
      pass "config_envs/ingestion APP_TOKENPUBLICKEY matches (exported from alias '$KP_ALIAS', $KP_ALIAS_SRC)"
    fi
  else
    skip "config_envs/ingestion"
  fi
else
  skip "ingestion JWT public key (sm-service.p12 not found in $EXPECTED_SRC_LABEL)"
fi

# ---------- 8. OS trust store (ca-trust) CA entry ----------
# The native scan worker validates TLS against the OS trust store, not
# the JVM's cacerts, so this is a separate copy of the root CA.
echo
echo "[8/9] OS trust store (ca-trust) CA entry"
CA_EXTRACTED="/etc/pki/ca-trust/extracted/pem/directory-hash/$ROOT_CA_NAME.pem"
if [[ -f "$CA_EXTRACTED" ]]; then
  EXPECTED_CA_FP=$(openssl x509 -in "$EXPECTED_CA_CERT" -noout -fingerprint -sha256 | cut -d= -f2)
  CUR_CA_FP=$(openssl x509 -in "$CA_EXTRACTED" -noout -fingerprint -sha256 | cut -d= -f2)
  if [[ "$CUR_CA_FP" != "$EXPECTED_CA_FP" ]]; then
    fail "OS trust store's extracted '$ROOT_CA_NAME' entry fingerprint $CUR_CA_FP, expected $EXPECTED_CA_FP ($EXPECTED_SRC_LABEL)"
  else
    pass "OS trust store's extracted '$ROOT_CA_NAME' entry matches ($CUR_CA_FP)"
  fi
else
  skip "/etc/pki/ca-trust (no $ROOT_CA_NAME entry found)"
fi

# ---------- 9. Public-facing (org_domain) HAProxy certificate ----------
# HAProxy's public :443 listener uses its own certificate directory,
# separate from ca/ and certificates/$analytics_internal_domain/. A
# mismatch shows up only in the browser ("unable to verify the first
# certificate"), never in a service log. The certificate is verified
# against the expected root CA rather than diffed against the bundle.
echo
echo "[9/9] Public-facing (org_domain) HAProxy certificate"
if [[ -n "${org_domain:-}" ]]; then
  ORG_CERT_FILE="$agilesec_install_dir/certificates/$analytics_hostname.$org_domain/agilesec-analytics-server-combo-cert-key.pem"
  if [[ -f "$ORG_CERT_FILE" ]]; then
    if openssl verify -CAfile "$EXPECTED_CA_CERT" "$ORG_CERT_FILE" >/dev/null 2>&1; then
      pass "$ORG_CERT_FILE verifies against the root CA from $EXPECTED_SRC_LABEL"
    else
      fail "$ORG_CERT_FILE does not verify against the root CA from $EXPECTED_SRC_LABEL"
    fi
  else
    skip "$ORG_CERT_FILE not found"
  fi
else
  skip "org_domain not set (export org_domain to check the public-facing HAProxy certificate)"
fi

# ---------- Summary ----------
echo
if [[ "$FAILURES" -eq 0 ]]; then
  echo "== All checks passed. =="
else
  echo "== $FAILURES check(s) failed. See Troubleshooting section of the guide. =="
fi
exit $(( FAILURES > 0 ? 1 : 0 ))

Sample output

Output from a validated restore on a three-node cluster, run with source_identity_bundle set (as in Stage 5 step 1). Paths are shown as placeholders. Each node skips checks for services they do not run. Both checklists end successfully with exit code 0.

backend-1
Bash
== Restore checklist (read-only) ==

-- Identity bundle vs certificates/ --
  [PASS] certificates/ matches the source identity bundle

[1/9] SM keystore (sm.properties)
  [PASS] keystore.password matches
  [PASS] keystore.cmkAlias matches (4e906bd11e96ae0c909e96ec97a6d582)
  [PASS] keystore.kpAlias matches (080065e4144647f103256c626f933872)

[2/9] OpenSearch's certificate copy
  [PASS] services/opensearch-2.19.6-2/config/certs/agilesec-internal-server-cert.pem matches (20047e3add93e2c2f4088574ab7b47d384ff1c8a35dc13ef6d3d8c48f1de73e7)
  [PASS] services/opensearch-2.19.6-2/config/certs/agilesec-internal-server-key.pem matches (f90acdf9b51fa1c037086eabee0ffd1e8cc037a7ca74938210e44d27f876bc6a)
  [PASS] services/opensearch-2.19.6-2/config/certs/agilesec-rootca-cert.pem matches (d4e36a80c8880c8e0f803bb1a650fd0e90ad7754a8dff2faa53f96bf050e5a62)

[3/9] JWT public key (api, cbom)
  [SKIP] config_envs/api (not present on this node)
  [SKIP] config_envs/cbom (not present on this node)

[4/9] SAML material for Advanced Dashboard
  [PASS] services/opensearch-2.19.6-2/config/opensearch-security/idp-metadata.xml certificate matches idp-cert.pem
  [SKIP] config_envs/api (SAML_PASSPHRASE) (not present on this node)
  [SKIP] services/api/dist/modules/v1/saml/config/privatekey.pem (not present on this node)

[5/9] scheduler/analytics-manager MongoDB TLS keystore password
  [PASS] bin/scheduler_entrypoint.sh keyStorePassword matches
  [PASS] bin/analytics_manager_entrypoint.sh keyStorePassword matches
  [PASS] config_envs/scheduler SCAN_WORKER_OPTION keyStorePassword matches

[6/9] JVM default truststore (cacerts) CA entry
  [PASS] cacerts alias 'root.kf-agilesec.internal' fingerprint matches (80:79:96:B7:0B:AD:C5:8B:D7:E8:EF:5C:EB:C7:43:54:43:EA:21:D1:BD:76:F4:5C:79:AD:84:63:3A:82:FA:B7)

[7/9] ingestion JWT public key
  [PASS] config_envs/ingestion APP_TOKENPUBLICKEY matches (exported from alias '080065e4144647f103256c626f933872', PrivateKeyEntry alias in sm-service.p12 (the source identity bundle (<source_identity_bundle>)))

[8/9] OS trust store (ca-trust) CA entry
  [PASS] OS trust store's extracted 'root.kf-agilesec.internal' entry matches (80:79:96:B7:0B:AD:C5:8B:D7:E8:EF:5C:EB:C7:43:54:43:EA:21:D1:BD:76:F4:5C:79:AD:84:63:3A:82:FA:B7)

[9/9] Public-facing (org_domain) HAProxy certificate
  [PASS] <agilesec_install_dir>/certificates/agilesec.kf-agilesec.com/agilesec-analytics-server-combo-cert-key.pem verifies against the root CA from the source identity bundle (<source_identity_bundle>)

== All checks passed. ==
frontend-1
Bash
== Restore checklist (read-only) ==

-- Identity bundle vs certificates/ --
  [PASS] certificates/ matches the source identity bundle

[1/9] SM keystore (sm.properties)
  [SKIP] sm.properties (or sm-service.p12 not found in the source identity bundle (<source_identity_bundle>)) (not present on this node)

[2/9] OpenSearch's certificate copy
  [PASS] services/opensearch-2.19.6-2/config/certs/agilesec-internal-server-cert.pem matches (20047e3add93e2c2f4088574ab7b47d384ff1c8a35dc13ef6d3d8c48f1de73e7)
  [PASS] services/opensearch-2.19.6-2/config/certs/agilesec-internal-server-key.pem matches (f90acdf9b51fa1c037086eabee0ffd1e8cc037a7ca74938210e44d27f876bc6a)
  [PASS] services/opensearch-2.19.6-2/config/certs/agilesec-rootca-cert.pem matches (d4e36a80c8880c8e0f803bb1a650fd0e90ad7754a8dff2faa53f96bf050e5a62)

[3/9] JWT public key (api, cbom)
  [PASS] config_envs/api PUBLIC_KEY matches (exported from alias '080065e4144647f103256c626f933872', PrivateKeyEntry alias in sm-service.p12 (the source identity bundle (<source_identity_bundle>)))
  [PASS] config_envs/cbom JWT_PUBLIC_KEY matches (exported from alias '080065e4144647f103256c626f933872', PrivateKeyEntry alias in sm-service.p12 (the source identity bundle (<source_identity_bundle>)))

[4/9] SAML material for Advanced Dashboard
  [PASS] services/opensearch-2.19.6-2/config/opensearch-security/idp-metadata.xml certificate matches idp-cert.pem
  [PASS] config_envs/api SAML_PASSPHRASE matches
  [PASS] services/api/dist/.../privatekey.pem matches idp-enc-key.pem (347a8d69244f618d39503b43ea8a658e5b48dfdd71efa731e65282f3f185c7ea)

[5/9] scheduler/analytics-manager MongoDB TLS keystore password
  [SKIP] bin/scheduler_entrypoint.sh (not present on this node)
  [SKIP] bin/analytics_manager_entrypoint.sh (not present on this node)
  [SKIP] config_envs/scheduler (not present on this node)

[6/9] JVM default truststore (cacerts) CA entry
  [PASS] cacerts alias 'root.kf-agilesec.internal' fingerprint matches (80:79:96:B7:0B:AD:C5:8B:D7:E8:EF:5C:EB:C7:43:54:43:EA:21:D1:BD:76:F4:5C:79:AD:84:63:3A:82:FA:B7)

[7/9] ingestion JWT public key
  [SKIP] config_envs/ingestion (not present on this node)

[8/9] OS trust store (ca-trust) CA entry
  [PASS] OS trust store's extracted 'root.kf-agilesec.internal' entry matches (80:79:96:B7:0B:AD:C5:8B:D7:E8:EF:5C:EB:C7:43:54:43:EA:21:D1:BD:76:F4:5C:79:AD:84:63:3A:82:FA:B7)

[9/9] Public-facing (org_domain) HAProxy certificate
  [PASS] <agilesec_install_dir>/certificates/agilesec.kf-agilesec.com/agilesec-analytics-server-combo-cert-key.pem verifies against the root CA from the source identity bundle (<source_identity_bundle>)

== All checks passed. ==