Skip to main content
Skip table of contents

Creating a Job Using Bash Scripting

Applies to PeerGFS v6.1.0 and later

Overview

This article expands on the workflow and high-level tasks described in Creating a Job Using Scripting.  It provides a detailed example of how to create a job using Bash and a job template.  This example demonstrates how to use a job template to pass user options on to the newly created job.

Task 1:  Configure NAS devices (if applicable)

Any NAS devices used for jobs need to be preconfigured in the Peer Management Center (PMC) user interface.

Step 1. Open the PMC, select Tools, and then select Open Preferences from the main menu.

1-Create job-PowerShell.png

Step 2. In the NAS Configuration section, select a platform and configure the NAS devices.

2-Create job-PowerShell.png

For more detailed guidance on setting up NAS devices, see the PeerGFS User Guide..

Task 2:  Create a template job

Creating a template job is useful when using the API to create jobs regularly.  The template allows you to set parameters that are not default or available through the API.

To create the template job, run the following API command in a Bash terminal:

NONE
./PeerGFS-cli.sh --insecure --host "https://$address:$port" -u "$username:$password" createJob jobName="TemplateJob" jobType=FILE_REPLICATION

The JobType parameter can be set to FILE_COLLABORATION, SYNCHRONIZATION_ONLY, or FILE_REPLICATION.

image-20250519-104011.png

Once created, the job will appear in the user interface with a unique icon, indicating that it has no participants.

3-Create job-PowerShell.png

Task 3: Edit options to be passed on to new jobs

Step 1. Right-click the job and select Edit Job.

4-Create job-PowerShell.png

Step 2. Make the necessary changes to the job. In this example, we are adjusting the transfer size.

Edit General.png

Step 3. Click OK to save the changes.

Task 4: Create the job

Once the previous tasks are complete, production jobs can be created via the API without further UI interaction.  To create the production job, run the following command using PowerShell:

POWERSHELL
./PeerGFS-cli.sh --insecure --host "https://$address:$port" -u "$username:$password" createJob jobName=LinuxJob jobType=FILE_REPLICATION refJobId=106

Where RefJobId is the job ID of the template job.

image-20250519-135417.png

If the returned job ID was not recorded, it can be retrieved by listing all jobs:

POWERSHELL
jobs=`./PeerGFS-cli.sh --insecure --host "https://$address:$port" -u "$username:$password" getJobs`
echo $jobs | python -m json.tool
image-20250519-135902.png

For scripting purposes, the job ID returned in the JSON-formatted response can be stored in a variable. For example:

POWERSHELL
export jobID=107

Task 5: Add participants to the job

Now that the job is created, participants need to be added.  Participants are paths within storage volumes (either NAS or local to Agents) for data movement to occur.

Step 1. List available storage devices

Run the following command to list available storage devices:

POWERSHELL
storage=`./PeerGFS-cli.sh --insecure --host "https://$address:$port" -u "$username:$password" getStorage`
echo $storage | python -m json.tool
image-20250519-144936.png

Storage volumes are returned as a JSON list, which can be processed logically or manually inspected. If volumes of a specific type are needed, the StorageDeviceType option can be used:

POWERSHELL
storage=`./PeerGFS-cli.sh --insecure --host "https://$address:$port" -u "$username:$password" getStorage storageDeviceType=DELL_POWERSCALE`
echo $storage | python -m json.tool

Example output (filtered for DELL_POWERSCALE):

image-20250519-145201.png

Step 2. Add Participants

Each participant must be added in turn. For replication jobs, there will only be one source participant. The following command adds the source participant:

POWERSHELL
./PeerGFS-cli.sh --insecure --host "https://$address:$port" -u "$username:$password" addParticipant jobId=$jobID storageDeviceId=LinuxAgent1:CLUSTER1 path=CLUSTER1:/ifs/workspace
image-20250519-145409.png

For all other participants, the -SeedingTarget $true option must be added:

CODE
./PeerGFS-cli.sh --insecure --host "https://$address:$port" -u "$username:$password" addParticipant jobId=$jobID storageDeviceId=LinuxAgent2:CLUSTER2 path=CLUSTER2:/ifs/workspace seedingTarget=true

Once all participants have been added, you can retrieve and view the job details:

POWERSHELL
./PeerGFS-cli.sh --insecure --host "https://$address:$port" -u "$username:$password" getJobs jobIds=$jobID | python -m json.tool
image-20250519-145655.png

Task 6: Start the job

Once the job has been fully configured, it needs to be started manually. To start the job, run the following command:

POWERSHELL
./PeerGFS-cli.sh --insecure --host "https://$address:$port" -u "$username:$password" startJob jobIds=$jobID
image-20250519-144106.png

After executing the command, the job will be in a running state. You can confirm this by checking the UI, where the job will now appear as running.

6-Create job-PowerShell.png
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.