Migrate Legacy Connected On-Prem to New KOTS-based Harness On-Prem

Updated 8 months ago by Michael Cretzman

If you are an existing Harness On-Prem customer using the legacy version of On-Prem, this topic will guide you through migrating your data into the new, KOTS-based Harness On-Prem.

This topic assumes you have already installed the new Harness On-Prem version.

In this topic:

Before You Begin

This topic is for migrating data to existing On-Prem installations. If you have not installed On-Prem, see Harness On-Premise Overview.

Step 1: Mongodump from Source On-Prem

You obtain the source On-Prem data using the mongodump utility.

Let's look at some example scripts.

These examples must be modified according to the type of installation.

The MONGO_URI value might be different in each installation. This value will be present in either the environment variable of the Docker container or in the harness-manager ConfigMap in the Kubernetes-based installation.

Here is an example using a legacy, 3 Box Docker On-Prem installation.

#!/usr/bin/env bash

set -e
set -x

# Get this information from the environment variable

#Get mongoDB dump

mongo_uri=$(echo ${MONGO_URI} | sed 's/\\//g')

mkdir -p $destination/$current_date
docker exec -i mongoContainer mongodump --uri="${mongo_uri}" --out /data/db/backup/dump
docker cp -a mongoContainer:/data/db/backup/dump $destination/$current_date
cd $destination/$current_date/ && tar -cvzf mongo.tar dump && cd -
rm -rf $destination/$current_date/dump

Here is an example using the legacy, Kubernetes-based installation:

#!/usr/bin/env bash

set -x
set -e


if [[ -z "${2}" ]]; then

current_date=$(date "+%Y.%m.%d-%H.%M.%S")

mkdir -p $destination/$current_date/dump

kubectl exec -it -n $namespace mongodb-replicaset-chart-0 -- mongodump --uri="mongodb://admin:CA8FMywpbM@mongodb-replicaset-chart-0.mongodb-replicaset-chart,mongodb-replicaset-chart-1.mongodb-replicaset-chart,mongodb-replicaset-chart-2.mongodb-replicaset-chart:27017/harness?replicaSet=rs0&authSource=admin" --out /data/db/backup/dump

kubectl cp -n $namespace mongodb-replicaset-chart-0:/data/db/backup/dump $destination/$current_date/dump
#Do not include the admin database to be copied over to the target
cd $destination/$current_date/ && tar -cvzf mongo.tar dump && cd -
rm -rf $destination/$current_date/dump/

Step 2: Restore Data on Destination On-Prem

Harness includes a restore script file in the new, KOTS-based Harness On-Prem. The file is named restore_harness.sh. You can get the file using the KOTS admin tool.

Run the restore script in the new KOTS-based Harness On-Prem installation using the output from the mongodump utility you ran in the previous step:

bash restore_harness.sh dump harness

You can open the file to see its script.

How did we do?