#!/usr/bin/env bash
<% if link('routing_api_db').p('release_level_backup') %>
set -ex

JOB_PATH="/var/vcap/jobs/bbr-routingdb"
SDK_PATH="/var/vcap/jobs/database-backup-restorer"

# Anything placed in the BBR_ARTIFACT_DIRECTORY by the backup script will be available to the restore script at restore time.
# The BBR CLI is responsible for setting the BBR_ARTIFACT_DIRECTORY
BBR_ARTIFACT_FILE_PATH="${BBR_ARTIFACT_DIRECTORY}/routing-api-db-backup"
CONFIG_PATH="${JOB_PATH}/config/config.json"

"${SDK_PATH}/bin/restore" --config "${CONFIG_PATH}" --artifact-file "${BBR_ARTIFACT_FILE_PATH}"
<% else %>
echo "script deactivated due to release_level_backup being set to FALSE\n"
<% end %>
