5 0 0:Task Name Template – Backup
Overview
As of 4.4.3 Beefalo V2, SEP sesam supports a higher level of automation for performing administrative work by generating administrative objects, such as backup tasks, based on a given template.
Templates can be created to allow SEP sesam administrators to automatically create backup tasks by replacing specific information with variables, thus saving time and simplifying backup management. Templates can be configured in the SEP sesam GUI -> Configuration -> Defaults -> Extras -> Template, as described in GUI Configuration options: Extras.
Backup task name template usage
SEP sesam used the Mustache specification for a templating language to auto-generate the name of backup tasks while creating the task using the UI server’s REST API. Due to some limitations of the Mustache template, SEP sesam introduced a more flexible and powerful Rythm template engine.
The Rythm template engine has the following advantages:
- Flexibility in writing template side code as it uses Java like syntax and allows embedding Java code snippets inside the template source.
- Easy to integrate into an existing Java application.
- Supports template inheritance as well as macros.
- Handling of complex data types.
For more details, see Rythm templates.
Note that you can also use the Rythm syntax to adopt the pre-configured report templates to suit your needs. For details, check the video Customized HTML Reports with SEP sesam.
Mustache syntax
Currently, SEP sesam auto-generates the name of the backup task by using the Mustache specification for a templating language. For example, if the name property of the backup task is set to backup_task_{{client}} and the client property of the backup task evaluates to snowfix, the UI server updates the name property of the backup task to backup_task_snowfix before committing this backup task to the database.
The syntax used by Mustache to denote a placeholder for named property is:
{{<property name>}}
Rythm syntax
The Rythm template engine uses a different syntax. The full Rythm template source for achieving the same result as in the example above is:
@args String client backup_task_@(client)
Note | |
There are no pre-configured backup templates available for customization. Until you configure a template, SEP sesam uses the default auto-generated names for backup tasks. |
Using placeholders
The following table lists placeholders that can be used in the backup task name template.
Name | Type | Description |
---|---|---|
client | string | The name of the client associated with the backup task object. |
source | string | The source property of the backup task object. |
count | string | A number between 1 and 10000. Evaluates to the first number in this range leading to a unique task name. |
count_optional | string | Equals the count token which is used when a task already exists. |
task | tasks | The backup task object. Note: This placeholder can only be used together with a native Rythm template. |
Functions (Mustache syntax only)
The following transformation functions are supported when using the Mustache syntax.
Note | |
These functions cannot be combined when using Mustache. If more complex transformations are required, use the Rythm syntax. |
Name | Description |
---|---|
toLower | Converts all characters in the placeholder value to lower case. |
toUpper | Converts all characters in the placeholder value to upper case. |
dashPrefix | Prepends a dash character (-) to the placeholder value, if the value is not blank. |
dotPrefix | Prepends a dot character (.) to the placeholder value, if the value is not blank. |
underPrefix | Prepends an underscore character (_) to the placeholder value, if the value is not blank. |
substring (start,end) | Evaluates to a string that is a substring of the string representation of the placeholder value. The character indices start with 0. |
replace (target,replacement) | Evaluates to a string where the target character sequence is replaced by the replacement character sequence. |
trimUnderPrefix | Removes any leading underscore character (_) from the placeholder value. |
trimUnderTrailing | Removes any trailing underscore character (_) from the placeholder value. |
Examples
In our example, the following placeholder values are used:
Name | Type | Value |
---|---|---|
client | string | SnowFix |
source | string | C:\work\test |
count | string | 10 |
Mustache
Using the Mustache syntax, the templates will evaluate as follows.
Name | Value |
---|---|
sep-task-{{client}} | sep-task-SnowFix |
sep-task-{{toLower client}} | sep-task-snowfix |
sep-task-{{toUpper client}} | sep-task-SNOWFIX |
sep-task-{{client}}-{{source}} | sep-task-SnowFix_C_work_test |
sep-task-{{client}}-{{substring(3,7) source}} | sep-task-SnowFix-work |
sep-task-{{client}}-{{replace("test","folder") source}} | sep-task-SnowFix_C_work_folder |
sep-task{{underPrefix count}} | sep-task_10 |
sep-task{{dashPrefix count_optional}} | sep-task (not exist) sep-task-0 (already exists) |
Rythm
Using the Rythm syntax, the templates will evaluate as follows.
Name | Value |
---|---|
@args String client;tasks_rythm_@(client) | tasks_rythm_SnowFix |
@args String client, String source;tasks_rythm_@(client.toLowerCase())_@(source.substring(3,7).toUpperCase()) | tasks_rythm_snowfix_WORK |
Shortcuts for backup task’s virtualization attributes
You can easily access all field names of the backup task virtualization attribute by using shortcuts. Each shortcut represents a field name of the attribute.
Valid virtualization attribute shortcuts: name, isVCenter, path, datacenter, moref, powerState, ipAddress, hostName, macAddress, hostSystem, cluster, version, guestFullName, uuid, sesamClient, folder, vapp, taskGroupRef, hostVersion
Example:
add task "@args de.sep.sesam.model.dto.VMDto vmDto;@ deb_ (vmDto.getMoRef())" …
is the same as
add task "@args String moref;deb_@(moref)"…
Example with direct virtualization attribute access:
add taskgen "@args de.sep.sesam.model.dto.FileDto fileDto;@(fileDto.getAdditionalInformationAsMap().get(\"Status\"))" "-c" "hypervdev" "-t" "Hyper-V" -s hyperV -f "c:\tmp\hyperv.txt" -G "hyperVGenGroup3"
add taskgen "@args de.sep.sesam.model.Tasks task;qs-@(task.getClient().getShortName())- @(task.getShortType())_@(task.getSourceSegment(0))" -f d:\input.json -O remove_all -G vm-8
Special shortcuts for easy access (without Rythm keywords)
The Rythm syntax is not required when using special shortcuts in tags – curly braces, i.e., {{<shortcut>}}.
The name generation shortcuts
Shortcut | Description |
---|---|
{{CLIENT_SHORT}} | get client without domain |
{{TASK_TYPE_SHORT}} | get short name of task type |
{{SOURCE_LAST_ITEM}} | get last source segment separated by slash |
{{SOURCE_ITEM[<pos>]}} | get segment pos separated by slash (negative pos as pos from back) |
{{<field>}} | use the description block field (cli action dir last param). Example: ...Status=Running,OwnerNode=HYPERVDEV,Clustered=No,uuid=2E4120B2-C0FC-4D99-8737-21EC5C9D7BC... {{uuid}}=2E4120B2-C0FC-4D99-8737-21EC5C9D7BC Note: You can use all description fields (UUID, folder, Guest OS,...) from output of the list (-f -) for task name. |
Examples
- Backup task with type Hyper-V from input stream:
sm_cmd dir -F JSON client "/hypervdev.sep.de/Hyper-V:" | sm_cmd add taskgen "gen_{{TASK_TYPE_SHORT}}_{{SOURCE_ITEM[1]}}-{{SOURCE_ITEM[-1]}}-{{uuid}}" "-t" "Hyper-V" –c hypervdev.sep.de -f - -O remove_all -G hv-5
- Backup task with type Hyper-V from file:
sm_cmd add taskgen "gen_{{TASK_TYPE_SHORT}}_{{SOURCE_ITEM[1]}}-{{SOURCE_ITEM[-1]}}-{{uuid}}" "-t" "Hyper-V" -c hypervdev.sep.de -f d:\hyperv.json -O remove_all -G hv-5
- Backup task with type Path from file:
sm_cmd add taskgen "{{CLIENT_SHORT}}-{{TASK_TYPE_SHORT}}_{{SOURCE_LAST_ITEM}}" -G pathgroup -f c:\root\path.json –t “Path”
See also
GUI Configuration options: Extras