Restoring Automation Decision Services

When needed, restore the secrets, the MongoDB collections, and the Decision Designer solutions that you backed up for Automation Decision Services.

Procedure

  1. Run the following command to make sure that you have the secrets ibm-dba-ads-mongo-secret, ibm-dba-ads-designer-secret (if you installed Decision Designer), and ibm-dba-ads-runtime-secret (if you installed the decision runtime server).
    kubectl get --namespace $ADS_RELEASE_NAMESPACE secrets

    If you do not have the secrets, you must restore them and make sure that the encryptionKeys value corresponds to the time of the MongoDB backup to be restored.

    Note: You might need a MongoDB administrator password to completely re-create embedded MongoDB databases. To obtain the generated password, you can use the following commands.
    export MONGODB_USER=$(kubectl get secret --namespace $ADS_RELEASE_NAMESPACE ibm-dba-ads-mongo-secret -o jsonpath="{.data.mongoUser}" | base64 --decode)
    export MONGODB_PASSWORD=$(kubectl get secret --namespace $ADS_RELEASE_NAMESPACE ibm-dba-ads-mongo-secret -o jsonpath="{.data.mongoPassword}" | base64 --decode)
  2. Get the value of the secrets and the name of the new MongoDB service.
    MONGO_URI=$(kubectl get secret --namespace $ADS_RELEASE_NAMESPACE ibm-dba-ads-mongo-secret -o jsonpath="{.data.mongoUri}" | base64 --decode)
    GIT_MONGO_URI=$(kubectl get secret --namespace $ADS_RELEASE_NAMESPACE ibm-dba-ads-mongo-secret -o jsonpath="{.data.gitMongoUri}" | base64 --decode)
    RUNTIME_MONGO_URI=$(kubectl get secret --namespace $ADS_RELEASE_NAMESPACE ibm-dba-ads-mongo-secret -o jsonpath="{.data.runtimeMongoUri}" | base64 --decode)
    
  3. If you want to restore into the embedded MongoDB instance instead of into an external instance (which is recommended in production), you must forward the MongoDB service port and adapt the MONGO_URI, GIT_MONGO_URI, and RUNTIME_MONGO_URI parts of the previous step.
    # Get ADS mongo service name
    export ADS_MONGO_SERVICE=$(kubectl get services --namespace $ADS_RELEASE_NAMESPACE -l 'app.kubernetes.io/name=ads-mongo' --output=jsonpath='{.items[0].metadata.name}')
    MONGO_URI="${MONGO_URI/@$ADS_MONGO_SERVICE*:/@localhost:}"
    GIT_MONGO_URI="${GIT_MONGO_URI/@$ADS_MONGO_SERVICE*:/@localhost:}"
    RUNTIME_MONGO_URI="${RUNTIME_MONGO_URI/@$ADS_MONGO_SERVICE*:/@localhost:}"
    kubectl port-forward --namespace $ADS_RELEASE_NAMESPACE svc/$ADS_MONGO_SERVICE 27017:27017 &
    
  4. To restore the Decision Designer collections that you backed up, you can use the mongorestore command.
    In the following command sample, the folders correspond to a backup from a deployment that uses the embedded MongoDB instance with its default database names (ads-db, ads-git-db, ads-runtime-archive-metadata). Adapt the paths to the names of the databases of your original Automation Decision Services instance.

    The ${MONGO_URI} and ${GIT_MONGO_URI} variables refer to the variables defined in substep c above and correspond to the URI for the new Automation Decision Services instance.

    mongorestore --uri "${MONGO_URI}" --tlsInsecure  adsbackup/ads-db/ads-db
    mongorestore --uri "${GIT_MONGO_URI}" --tlsInsecure  adsbackup/ads-git-db/ads-git-db
    
  5. To restore the collections of the decision runtime server, you can use the following mongorestore command.
    mongorestore --uri "${RUNTIME_MONGO_URI}" --tlsInsecure adsbackup/ads-runtime/ads-runtime-archive-metadata