Clone from Primary to Standby Environment Daily After Daily Maintenance is Complete on the Primary Environment
To keep the standby environment up to date with the primary environment, use these scripts to clone Oracle Enterprise Performance Management Cloud primary environment to the standby environment soon after the daily maintenance is complete on the primary environment.
These custom scripts identify whether the scheduled daily maintenance for the day is complete and then clone the environment.
Windows Script
Createdailyclone.ps1
by copying the following PowerShell
script.# Clone Environment script
#
# Update the following parameters
# -------------------------------
$users_and_predefined_roles="false"
$daily_maintenance_start_time="true"
$data_management="true"
$app_audit="true"
$job_console="true"
$stored_snapshots_and_files="false"
# -------------------------------
$source_username=$args[0]
$source_password=$args[1]
$source_url=$args[2]
$target_username=$args[3]
$target_password=$args[4]
$target_url=$args[5]
if ($($args.count) -ne 6) {
echo "Usage: ./dailyclone.ps1 <SOURCE USERNAME> <SOURCE PASSWORD> <SOURCE URL> <TARGET USERNAME> <TARGET PASSWORD> <TARGET URL>"
exit 1
}
$amw_time=""
function getDailyMaintenanceStartTime {
$amwstring=$(epmautomate.bat getDailyMaintenanceStartTime)
$elements=$amwstring.split(' ')
$amwtime=$elements[0]
return $amwtime
}
function goToSleep ($amw_time){
$current_mdy=Get-Date -AsUTC -UFormat "%m/%d/%Y"
$current_date_time=Get-Date -AsUTC -UFormat "%m/%d/%Y %H:%M:%S"
$current_epoch=Get-Date -Date $current_date_time -UFormat "%s"
$target_date_time=[DateTime]"${current_mdy} ${amw_time}"
$target_epoch=Get-Date -Date $target_date_time -UFormat "%s"
$sleep_seconds=$target_epoch - $current_epoch
# Today's AMW start time has already passed, so add 24 hours to sleep_seconds
if ($sleep_seconds -lt 0) {
$sleep_seconds=$sleep_seconds + 86400
}
$sleep_ts=New-TimeSpan -Seconds ${sleep_seconds}
$sleep_hms="${sleep_ts}" -replace '^\d+?\.'
echo "Current time is ${current_date_time}. Sleeping for ${sleep_hms}, until daily maintenance start time of ${amw_time}."
Start-Sleep -Seconds $sleep_seconds
}
function deleteArtifactSnapshotIfExists {
if (artifactSnapshotExists) {
$command_del=$(epmautomate.bat deletefile "Artifact Snapshot")
}
}
function artifactSnapshotExists {
$filelist=$(epmautomate.bat listfiles)
if ("$filelist".contains("Artifact Snapshot")) {
return $true
else
return $false
}
}
function cloneEnvironment {
echo "Checking to see if daily maintenance processing has completed ..."
while ($true) {
if (artifactSnapshotExists) {
echo "Daily maintenance processing has completed ..."
break
} else {
echo "Sleeping for 30 seconds before the next check to see if daily maintenance processing has completed ..."
Start-Sleep -Seconds 30
}
}
echo "Encrypting target password ..."
epmautomate.bat encrypt "${target_password}" "oracleKey" "target_password.epw"
echo "Cloning environment ..."
epmautomate.bat cloneEnvironment "${target_username}" "target_password.epw" "${target_url}" "SnapshotName=Artifact Snapshot" "UsersAndPreDefinedRoles=${users_and_predefined_roles}" "DataManagement=${data_management}" "appAudit=${app_audit}" "jobConsole=${job_console}" "storedSnapshotsAndFiles=${stored_snapshots_and_files}" "dailyMaintenanceStartTime=${daily_maintenance_start_time}"
}
echo "Beginning clone environment script."
echo "Logging into server ..."
epmautomate.bat login ${source_username} ${source_password} ${source_url}
$amwtime=getDailyMaintenanceStartTime
goToSleep ($amwtime)
deleteArtifactSnapshotIfExists
cloneEnvironment
echo "Logging out of server ..."
epmautomate.bat logout
echo "Clone environment script processing has completed."
Linux/UNIX Script
Createdailyclone.sh
by copying the following
script.#!/bin/bash
# Update the following parameters
# -------------------------------
epmautomatescript="LOCATION_EPM_AUTOMATE_EXECUTABLE"
javahome="LOCATION_JAVA_HOME"
users_and_predefined_roles="false"
data_management="true"
app_audit="true"
job_console="true"
stored_snapshots_and_files="false"
daily_maintenance_start_time="true"
# -------------------------------
source_username="$1"
source_password="$2"
source_url="$3"
target_username="$4"
target_password="$5"
target_url="$6"
export JAVA_HOME=${javahome}
if [ "$#" -ne 6 ]; then
echo "Usage: ./dailyclone.sh SOURCE_USERNAME SOURCE_PASSWORD SOURCE_URL TARGET_USERNAME TARGET_PASSWORD TARGET_URL"
exit 1
fi
amw_time=""
getDailyMaintenanceStartTime() {
amw_time=$(${epmautomatescript} getDailyMaintenanceStartTime | cut -d' ' -f1)
}
goToSleep() {
current_mdy=$(date -u +%m/%d/%Y)
current_date_time=$(date -u)
current_epoch=$(date +%s)
target_epoch=$(date -d "${current_mdy} ${amw_time}" +%s)
sleep_seconds=$(($target_epoch - $current_epoch))
# Today's AMW start time has already passed, so add 24 hours to sleep_seconds
if [[ ${sleep_seconds} -lt 0 ]]
then
sleep_seconds=$((sleep_seconds + 86400))
fi
sleep_hms=$(date -d@${sleep_seconds} -u +%H:%M:%S)
echo "Current time is ${current_date_time}. Sleeping for ${sleep_hms}, until daily maintenance start time of ${amw_time}."
sleep $sleep_seconds
}
deleteArtifactSnapshotIfExists() {
found=1
filelist=$(${epmautomatescript} listfiles)
if [[ ${filelist} == *"Artifact Snapshot"* ]]
then
command_del=$(${epmautomatescript} deletefile "Artifact Snapshot")
fi
}
artifactSnapshotExists() {
found=1
filelist=$(${epmautomatescript} listfiles)
if [[ ${filelist} == *"Artifact Snapshot"* ]]
then
found=0
else
found=1
fi
echo ${found}
}
cloneEnvironment() {
local found=1
while true
do
found=$(artifactSnapshotExists)
if [[ ${found} -eq 0 ]]
then
echo "Daily maintenance processing has completed ..."
break
else
echo "Sleeping for 30 seconds before the next check to see if daily maintenance processing has completed ..."
sleep 30
fi
done
echo "Encrypting target password ..."
${epmautomatescript} encrypt "${target_password}" "oracleKey" "target_password.epw"
echo "Cloning environment ..."
${epmautomatescript} cloneEnvironment "${target_username}" "target_password.epw" "${target_url}" "SnapshotName=Artifact Snapshot" "UsersAndPreDefinedRoles=${users_and_predefined_roles}" "DataManagement=${data_management}" "appAudit=${app_audit}" "jobConsole=${job_console}" "storedSnapshotsAndFiles=${stored_snapshots_and_files}" "dailyMaintenanceStartTime=${daily_maintenance_start_time}"
}
echo "Beginning clone environment script."
echo "Logging into server ..."
${epmautomatescript} login ${source_username} ${source_password} ${source_url}
getDailyMaintenanceStartTime
goToSleep
deleteArtifactSnapshotIfExists
cloneEnvironment
echo "Logging out of server ..."
${epmautomatescript} logout
echo "Clone environment script processing has completed."
Running the Script
- Create
dailyclone.ps1
ordailyclone.sh
by copying a script from one of the preceding sections. - Update these values in
dailyclone.sh
:epmautomatescript
with the location of the EPM Automate executable. Example:epmautomatescript="/home/utils/EPMAutomate/bin/epmautomate.sh"
javahome
with the directory where the JDK used by EPM Automate is installed. For example:"/home/user1/jdk1.8.0_191"
- Update these values in
dailyclone.ps1
anddailyclone.sh
, if required:users_and_predefined_roles
: Set this value totrue
to clone users and their predefined role assignments (Access Control groups are always cloned).data_management
: Set this value tofalse
to not clone Data Integration records. Note that Data Integration records can be cloned only if both the source and target environments are on the same monthly update or the target environment is one update newer than the source environment. For example, you can clone 22.01 Data Management records to another 22.01 environment or to a 22.02 environment only.Ignored for Narrative Reporting and Oracle Enterprise Data Management Cloud environments.
app_audit
: Set this value tofalse
if you do not want to clone the application audit data for Planning, FreeForm, and Enterprise Profitability and Cost Management applications.Financial Consolidation and Close and Tax Reporting audit information is always cloned.
job_console
: Set this value tofalse
if you do not want to clone job console data.stored_snapshots_and_files
: Set this value totrue
if you want to clone the contents of the top level folders in the inbox and outbox (subfolders are never cloned) of the source environment.daily_maintenance_start_time
: Set this value tofalse
if you do not want to reset the maintenance start time of the cloned target environment to that of the source environment.
- Run
dailyclone.ps1
ordailyclone.sh
: In a Command Window, or shell, navigate to the folder wheredailyclone.ps1
ordailyclone.sh
is stored and then execute a command:- Windows:
./dailyclone.ps1 SOURCE_USERNAME SOURCE_PASSWORD SOURCE_URL TARGET_USERNAME TARGET_PASSWORD TARGET_URL
- Linux/UNIX:
./dailyclone.sh SOURCE_USERNAME SOURCE_PASSWORD SOURCE_URL TARGET_USERNAME TARGET_PASSWORD TARGET_URL
where:SOURCE_USERNAME
is the user name of a Service Administrator. Identity Domain Administrator role is required to clone users and predefined roles.SOURCE_PASSWORD
is the password of the user identified bySOURCE_USERNAME
.SOURCE_URL
is the URL of the environment that you want to clone.TARGET_USERNAME
is the user name of a Service Administrator. Identity Domain Administrator role is required to clone users and predefined roles.TARGET_PASSWORD
is the password of the user identified byTARGET_USERNAME
.TARGET_URL
is the URL of the target environment.
- Windows: