Ask or search…
K

Copia Scripting

Overview

The Copia Script type allows you to automate your own custom scripts to backup a Device. This is handy when the Device has a command-line interface, backup script, or simple API for producing a backup. Using PowerShell, Batch, VB, C#, or any Windows-executable scripting language, the Copia Agent can automate your creation to backup and compare your Devices.

Agent Requirements

Below are the Agent system requirements to configure a Copia Agent for the backups using scripts:
  • The Agent should be tested to confirm that it can backup the desired files utilizing the script on the Agent.

Scripts

Prior to configuring a Project in Copia, it is important to have created a script that is proven and tested to create a backup of the desired Project data. A script can be written in any Windows-executable format (batch, Powershell, C#, etc.).
There are a few requirements for the script:
  • Results should be placed in the %temp%\backup_results\ folder Copia will pre-create this folder prior to running the script, and it should contain the results of the script execution (i.e. the backup data)
    • NOTE: prior to sending the data to Copia, the results will be compressed into a zip file with the Job ID as the name. If after testing this zip is found to be empty, it is likely your script did not complete as expected.
  • CopiaError.log Copia will prepopulate the %temp%\backup_results\ folder with a CopiaError.log file. You should always delete this file as part of your script! If the file is deleted, Copia will accept the results. If the file is not deleted, Copia will assume the script has crashed or failed to execute. You can also write log messages to the file, to improve troubleshooting in these failure cases.
  • Existing project data will be made available for the script in %temp%\backup_data Copia will bring the existing project data down to the Agent and place it in this folder. This will allow you to use this data (such as copying it to the results, and updating it) in any manner you may see fit.
  • The script must exist on the Agent Either you can store the script locally on the Agent, or you can store the script alongside the Project data and then execute it from the %temp%\backup_data folder. The second option allows you to track changes to the script in tandem with your backup data. If you decide to pursue the second option, make sure to re-copy the script to the %temp%\backup_results folder prior to completion.
  • Test the script on the Agent prior to configuration using the command-line The Agent will execute the script in a similar manner to using the command-line to execute a process. (for example, if it is a PowerShell script, then the Windows association for ps1 files should be PowerShell) The script should be able to be manually executed in this manner, and it should be able to backup and place the resulting data in the %temp%\backup_results folder.

Project Configuration

Script projects require a File List to determine what files in the %temp%\backup_results folder to include and exclude, as well as the contents to exclude from the compare. While you can simply grab all files in the directory, if you need additional filtering or need to ignore certain files during the compare operation, you can do this via the file list creation.
Copia recommends that you create a File List prior to creating a Project. More information can be found in File List section.
If you will have multiple projects of the same type, like a Network Switch Configuration, then a File List called "NetworkSwitch_Type1" may be a good name, and can be used for multiple Script projects to backup multiple network switches.
To configure a Project as a Script, you need a repository with a Project folder to store the data. The name of the folder is usually similar to that of the robot or controller. Your Project will need to point to that folder.
The folder can be created during the project creation process.
Click either of the Add a Project buttons in the Projects tab.
The Add a new project configuration dialog will appear which allows you to fully configure the project, devices and job for the project.
Any items highlighted with an asterisk are required.
This is a multi-step process with each section explained in detail. At any time, you can edit the prior section of this workflow.
The project can be edited after creation. Devices and Jobs can also be edited or created directly, using the Devices or Jobs tab. The steps for creation are similar to the steps provided below for those sections.

Define the Project

To get started, we will first select the Project Type from the list provided, and then select an Agent. If you have not already created an Agent, you can create and assign an Agent at a later time. See more about this in the Agents section of the documentation.
When complete, press Save and Continue.
You will now select the Project Path, which is the location (Repo/Branch) that the project is, or will be stored.
You can edit the previous steps at any time.
For Scripting, you can either select an existing folder, or create a new empty folder (so that you can upload a copy of your project data from the device) for an initial revision. You can make this choice after you have selected the repository and branch for the project folder.
In this example, we will create a new empty project folder. Once complete, press Save and Continue to proceed.
Once selected, press Save and Continue to proceed.
The project details allows you to update the Project name, and description if desired.
The name of the Project will pre-populate with the folder name that you selected. Add a description and select the Script type. You will need to provide two pieces of information:
  • Script Path The script path is the location of the script (on the Agent) to be run.
  • File List A File List is a list of files to be included/excluded in the backup, and also what may be excluded from Compare. In this field you will select the File List for this Device type. This is optional and can be set later on the Project. See the File List section for more details.

Define the Device(s)

Since the Script exists on the Agent, there is no need to define a Device for Projects that use a Script during setup. You can skip to the Job section.

Define the Job(s)

Creating Jobs is similar for all vendor types, and is described in the Creating Jobs section. It is recommended to review that section while completing a job configuration, and press Save to save the job. You can create more than one job for a device if desired.

Submit the Configuration

Once complete, press Submit Project Setup to create the Project, Device(s) and Job(s).
Don't forget to enable/disable the Watch button, based on your preferences for project Notifications.