Thursday, 3 October 2019

EPM Automate Migrating large Snapshots using: copysnapshotfrominstance

Create a simple script to manage your migration process between environments. This script will give you peace of mind that, no matter how large your Snapshots grow, you can effortlessly migrate them across environments.

Key benefits:
  • The migration of Snapshots can be scheduled,
  • The command can handle large Snapshot sizes,
  • Significantly faster than manual Download / Upload process,
  • Less risk of storing sensitive Snapshots locally,
  • Less storage space required locally.

Points to note:
  •         A separate command importsnapshot could be used to Import the Snapshot, if desired.
  •         The Snapshot will be copied from the Migration area in the Source environment to the Target Environment
  • The source password will need to be encrypted, whereas this is not a requirement for the target password

Here are the building blocks for your script:
1.       Set Variables
 I use the following variables in my script:
 -  Location of epmautomate.bat file
               SET %EPMAUTOMATE% = "C:\Oracle\EPM Automate\bin\epmautomate.bat"
           -  User friendly name of Target Environment (for renaming Snapshots)
      -  URL of Target Environment
         %TARGET_URL% =
       - Domain ID of Target Environment
        %TARGET_ID_DOMAIN% = a12345
     -   Username for Target Environment
               SET %TARGET_USER% = EPMTargetUsername
            -   Password or encrypted password file
         SET %TARGET_PASSWORD_FILE% = C:\Scripts\PreProdPassword.epw
       - URL of Source Environment
        %SOURCE_URL% =
     -  Domain ID of Source Environment
        %SOURCE_ID_DOMAIN% = a54321
     -  Username for Source Environment
        %SOURCE_USER% = EPMSourceUsername
            -  Location and name of password encryption file which will be created within script
        %SOURCE_PASSWORD_FILE% = C:\Scripts\ProdPassword.epw

2.       Login to Target Environment
 The password provided via an encrypted file here, but this is optional.


3.       Prompt for Password of User for Source Environment
 The user must be a Service Administrator.

           echo Username = %SOURCE_USER%
set /P SOURCE_PASSWORD=Please enter EPM Automate password:

The Source Password must be encrypted. Instead of prompting for the password, you can maintain an encrypted password file using a separate script and set SOURCE_PASSWORD_FILE as a variable in the beginning of the script.

4.    Prompt for Snapshot Name
This prompt will appear in the command line window. The response will be saved in the SNAPSHOT_NAME variable. This Snapshot will be copied from Source to Target.

set /P SNAPSHOT_NAME=Please enter the name of an existing Snapshot to be migrated. Use double quotes:

Alternatively, set SNAPSHOT_NAME as “Artifact Snapshot” or any desired Snapshot name without prompting.

5.       Rename Snapshot in Target Environment
Use the RenameSnapshot command, if necessary, to rename Snapshots in the target environment. For example, if you are copying the Artifact Snapshot from the Production environment to Pre-Production, you will need to rename the Artifact Snapshot in Pre-Production to avoid overwriting it. 
Renaming the Snapshot in the Source Environment would require a separate set of login / logout commands.
Keep clear naming conventions such as FullSnapshot_PreProd_Date.

          call %EPMAUTOMATE% renamesnapshot "Artifact Snapshot"                                            ArtifactSnapshot_%EPBCS_TARGET_ENV%_%DATE:/=-%

6.       Encrypt password
This is compulsory.  The copysnapshotfrominstance command requires an encrypted password file.


I set the Password Key as any random word.

7.       Copy Snapshot from Source Migration to Target Migration
(Does not import the Snapshot)

          call %EPMAUTOMATE% copysnapshotfrominstance %SNAPSHOT_NAME%                %SOURCE_USER% %SOURCE_PASSWORD_FILE% %SOURCE_URL%                            %SOURCE_ID_DOMAIN%

8.       Delete encrypted password file – Optional

          del %SOURCE_PASSWORD_FILE% /q

9.       Logout

call %EPMAUTOMATE% logout