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.
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.
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)
- 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. 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.
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.
First, select the Repository that you store (or want to store) your devices project data.
Next, choose a Branch of the repository for the Project folder. Our example repository only has a single branch, so we will select the "master" (or main) branch.
Select the folder that you want to store the Device data within. If the folder does not already exist, check the Create and select a new directory option. This will display a new field, allowing you to declare the name of a new directory in this location. The directory will contain the Project data resulting from the backup. Click Next to continue.
Since Git does not allow empty directories, a hidden
.gitkeepfile is created in the directory to allow its creation. This can be removed after the project data has been added, 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.
Finally, select the Agent that will run the script, and click on Create Project to finish project setup.
If this is not your first Project, and you have already created an Agent and Device, you can assign them to the project while creating it. You can always connect the Project to an Agent or Device at a later time.
You'll notice that any Project you create will display a teal eyeball in the top right corner of the project card. This means that you are watching that Project and therefore receiving notifications about its backup activity.
If you do not want to receive notifications for a given Project, simply click on the Watch button on the Project card to unwatch the Project.
You have added a Project to the Site.
Since the Script exists on the Agent, there is no need to define a Device for Projects that use a Script during setup.