# CLI Reference

## Overview

Every node provides CLI that can be used to manage configuration and invoke tasks on vPlus Node. All of the commands are executed using `vprotect` command. The general syntax is as shown below:

```bash
vprotect
# usage: vprotect <COMMAND> -<ARG_1> ... -<ARG_N>
# COMMAND is one of the following:
#  node                   Node management
#  config                     Node configuration management
#  hv                         Hypervisor management
#  hvm                        Hypervisor manager management
#  hc                         Hypervisor cluster management
#  hs                         Hypervisor storage management
#  vm                         Virtual machine management
#  vmpolicy                   VM backup policy management
#  bd                         Backup destination management
#  sched                      Schedule management
#  brvm                       VM backup & restore
#  st                         Storage management
#  stpool                     Storage pool management
#  stprovider                  Storage provider management
#  brapp                      Application backup & restore
#  mnt                        Mounted backup management
#  task                       Task management
#  login                      User login
#  logout                     Node and user logout
#  stop                       Safely stops node
#  vm-snappolicy              Snapshot policy management for VMs
#  storage-snappolicy          Snapshot policy management for storages
#  app                        Application backup management
#  appconf                    App command execution management
#  apppolicy                  Application backup policy management
#  restorejob                  Restore jobs
#  recplan                    Recovery plan policies
#  brst                       Storage backup & restore
#  quota                      Quota management
#  project                    Project management
#  user                       User management
#  rbac                       Rbac management
#  role                       AppUser Role management
#  group                      AppUser Group management
#  status                     Shows node status
#  start                      Starts node
```

## Starting and stopping node

*   To check if vPlus Node is running, run:

    ```bash
    systemctl status vprotect-node
    ```

    or

    ```bash
    vprotect status
    ```
*   To start vPlus Node run:

    ```bash
    systemctl start vprotect-node
    ```

    or

    ```bash
    vprotect start
    ```
*   To safely stop vPlus Node (this command waits for all tasks to be canceled, so that temporary objects are cleaned up) run:

    ```bash
    systemctl stop vprotect-node
    ```

    or

    ```bash
    vprotect stop
    ```
*   In emergency cases you may need to kill the engine without task clean up - get PID of the node by running:

    ```bash
    vprotect status
    ```

    and kill process using:

    ```bash
    kill <PID>
    ```

## User login

*   To log in to CLI use the following command:

    ```bash
    vprotect login -u USER_NAME
    ```

where `USER_NAME` is your admin account in vPlus. You will be prompted for a password. From this moment you are able to execute commands.

*   Once you completed working with CLI, you can log out by running:

    ```bash
    vprotect logout -u
    ```

## Note about GUIDs

All of the commands require GUID of the object that you want to refer to in the command. GUID is found in the first column of typical list command, e.g.:

1.  Let's list VMs and get VM GUID:

    ```bash
     vprotect vm -l
                     <!-- GUID                              Name                   Hypervisor       Present   VM group    Protected       Last backup
     ------------------------------------  -----------------------------  -------------------  -------  -----------  ---------  ----------------------
     b2555a74-97bb-44e4-9c68-ed1ac2ddffcd  Windows 7 (32-bit)            xcp-ng.vplus.local  true    PM-T1_Group  false      2020-06-03 00:30 (Tue) -->
    ```
2.  Now let's show details of the VM:

    ```bash
    vprotect vm -g b2555a74-97bb-44e4-9c68-ed1ac2ddffcd
    <!-- Property                                      Value
    --------------------------------------------  ------------------------------------------------------------

    GUID                                          b2555a74-97bb-44e4-9c68-ed1ac2ddffcd
    Name                                          Windows 7 (32-bit)
    UUID                                          9a486d85-c5c6-868b-50f4-3b27f4e4f968
    Present                                       true
    HV type                                       CITRIX
    HVM type                                      -
    Inc. backup snapshot                          Windows 7 (32-bit): 2020-06-15 19:10:22.0 (6626e7d9-0900-4bfa-a961-85f5379b48d4)
    Tags                                          [vPro-Citrix]
    Hypervisor                                    10.40.0.29 (1048d561-b0f5-4f1d-b558-856b28e0283e)
    HV manager                                    -
    Backups                                       29
    VM backup policies                            Citrix Hypervisor | XCP-ng (1f02821f-75f9-433f-9698-5694f130e1df)
    Protected                                     true
    Last backup                                   2020-06-15 19:10 (Mon)
    Warnings present                              true
    VM export/import mode                         INHERIT
    Quiesce/freeze before snapshot                false
    SSH host                                      -
    SSH port                                      22
    SSH user                                      -
    SSH key path                                  -
    Pre-snapshot CMD exec. enabled                false
    Pre-snapshot CMD                              []
    Post-snapshot CMD exec. enabled               false
    Post-snapshot CMD                             []
    Pre-snapshot ignored exit codes               -
    Pre-snapshot standard error output handling   DONT_IGNORE
    Post-snapshot ignored exit codes              -
    Post-snapshot standard error output handling  DONT_IGNORE -->
    ```

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> UUID is the ID used by the hypervisor or HV manager, while GUID is the ID used by vPlus to uniquely identify objects.
{% endhint %}

Node GUID can be replaced by `this` keyword to state that action such as restore or mount is going to be run on the node where the command is executed from. For instance, to restore or backup with given GUID on current node to `/vprotect_data`:

```bash
vprotect br -r 2132182d-e9ab-4478-a1db-48222b0e515b this /vprotect_data
```

Similarly, backup destinations can be referred to by names. So a backup of some VM with given GUID to backup destination with name `ISP` can be done like this:

```bash
vprotect br -b b6f96d43-6f55-468f-a7a0-8aa6219fdf4e ISP
```

## Nodes

To list or register node use `vprotect node` sub-command:

```bash
vprotect node
# Incorrect syntax: Missing required option: [-r Register node, -R Check and Register node, -d Delete node, -e Register existing node, -l List nodes]

# usage: node -d <GUID | NAME> | -e <NODE_NAME> <ADMIN_LOGIN> <API_URL> <[PASSWORD]> | -l | -r <NODE_NAME> <ADMIN_LOGIN> <API_URL> <[PASSWORD]> | -R <NODE_NAME> <ADMIN_LOGIN> <API_URL> <[PASSWORD]>
# Node management
#  -d,--delete <GUID | NAME>                                                  Delete node
#  -e,--register-existing <NODE_NAME> <ADMIN_LOGIN> <API_URL> <[PASSWORD]>    Register existing node
#  -l,--list                                                                  List nodes
#  -r,--register <NODE_NAME> <ADMIN_LOGIN> <API_URL> <[PASSWORD]>             Register node
#  -R,--check-and-register <NODE_NAME> <ADMIN_LOGIN> <API_URL> <[PASSWORD]>   Check and Register node
```

### Examples (Nodes)

*   To list all nodes registered

    ```bash
    vprotect node -l
    ```
*   Example node registration

    ```bash
    vprotect node -r node1 admin https://localhost:8181/api
    ```
*   You may need to re-register a node if vPlusServer address changes

    ```bash
    vprotect node -e node1 admin https://localhost:8181/api
    ```

## Node configurations

Use `vprotect config` sub-command add/remove backup destinations from node config, list, or show details of node configs.

```bash
vprotect config
# Incorrect syntax: Missing argument for option: s

# usage: config -b <CONFIG_GUID> <[BD_GUID|BD_NAME],...,[BD_GUID|BD_NAME]> | -c <NAME> | -d <GUID> | -g <GUID> | -l | -r <CONFIG_GUID> <[BD_GUID|BD_NAME],...,[BD_GUID|BD_NAME]> | -s <GUID> <PROPERTY_NO.> <VALUE | "MAPPING1=VALUE1;MAPPING2=VALUE2">

# Node configuration management
#  -b,--add-backup-destinations <CONFIG_GUID> <[BD_GUID|BD_NAME],...,[BD_GUID|BD_NAME]>      Add backup destinations
#  -c,--create <NAME>                                                                        Create node config
#  -d,--delete <GUID>                                                                        Delete node config
#  -g,--details <GUID>                                                                       Show config details
#  -l,--list                                                                                 List node configs
#  -r,--remove-backup-destinations <CONFIG_GUID> <[BD_GUID|BD_NAME],...,[BD_GUID|BD_NAME]>   Remove backup destinations
#  -s,--set <GUID> <PROPERTY_NO.> <VALUE | "MAPPING1=VALUE1;MAPPING2=VALUE2">                Modify node config.
```

### Setting up parameters for node configuration

In general `vprotect config -s <GUID> <PROPERTY_NO.> <VALUE>` the command sets the value of a property with the given number of node configurations with `GUID`. Property numbers are returned in a detailed view of each node configuration. After you create node configuration, show default values with `-g`. Then use property numbers (the first number in the property/value line of the detailed view).

### Examples (Node configurations)

*   To list all node configurations

    ```bash
    vprotect config -l

                    <!-- GUID                       Name       Default  Nodes  Backup destinations  Modification time
    ------------------------------------  --------------  -------  -----  -------------------  -----------------
    c95fb3cc-e567-11eb-8446-566fc400002d  Default Config  true     1      1                    2021-07-16 11:41 -->
    ```
*   To show details of the given node config (by GUID)

    ```bash
    vprotect config -g c95fb3cc-e567-11eb-8446-566fc400002d

    # Property                                                     Value
    # -----------------------------------------------------------  ------------------------------------------------------------

    # GUID                                                         c95fb3cc-e567-11eb-8446-566fc400002d
    # Modification time                                            2021-07-16 11:41:54
    # 1. Name                                                      Default Config
    # 2. Default                                                   true
    # 3. Export path                                               /vprotect_data
    # 4. Import path                                               /vprotect_data/import
    # 5. Mount path                                                /vprotect_data/mount
    # 6. Max. backup time diff. [sec.]                             60
    # 7. Keep last backups locally                                 false
    # 8. Min. free space for export (staging space threshold) [%]  10
    # 9. Minimal free space for snapshot in bytes                  0
    # 10. Minimal free space for snapshot in percentages           0
    # 11. Max. no. of inventory synchronization threads            1
    # 12. Max. no. of export threads                               3
    # 13. Max. no. of export threads                               3
    # 14. Max. no. of export threads per source                    2
    # 15. Max. no. of store threads                                3
    # 16. Max. no. of restore threads                              3
    # 17. Inventory synchronization task timeout [min.]            1h
    # 18. Export task timeout [min.]                               5h
    # 19. Store task timeout [min.]                                5h
    # 20. Restore task timeout [min.]                              1h
    # 21. Unmount task timeout [min.]                              1h
    # 22. Mount task timeout [min.]                                1h
    # 23. Import task timeout [min.]                               1h
    # 24. Old backups removal task timeout [min.]                  1h
    # 25. Snapshot reversion task timeout [min.]                   1h
    # 26. Old snapshot removal task timeout [min.]                 1h
    # 27. Task snapshot timeout [min.]                             1h
    # 28. Max. no. of snapshot threads                             5
    # 29. Max. no. of snapshots threads per source                 2
    # Backup destinations                                          [backup [FILESYSTEM] (bb0524fe-40a1-4ca3-bbc9-7f0be8ac73cc)]
    ```
*   To add backup destination (second GUID) to the given node configuration (first GUID):

    ```bash
    vprotect config -b c95fb3cc-e567-11eb-8446-566fc400002d f27b6018-ce1c-4d67-991e-31d9f4f6662b
    ```

    More backup destinations can be added by separating GUIDs with commas.

## Backup destinations

The backup destination management module is used to add and remove a backup destination (a backup provider instance with retention settings). A backup destination must be assigned to a group for the scheduler to know where to put backups during automatic backup. For on-demand backup, you just need to specify which backup destination should be used.

Backup destinations are assigned to the node configuration. This means that nodes using such configuration are configured to store backups in the selected backup destinations.

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> The backup task will fail if it is not able to assign a node because the given BD is not assigned to the node config of the node that is required to be used for the given hypervisor.
{% endhint %}

To manage backup destinations in the system used `vprotect bd` sub-command.

```bash
vprotect bd
# Required option: [-r Reinitialize backup destination, -c Create backup destination (type = ["filesystem", "netbackup", "networker", "s3", "swift", "isp", "azure", "gcs", "avamar"]), -s Modify backup destination, -d Delete backup destination, -D Remove old backups, -g Show backup destination details, -l List backup destinations]

# usage: bd -c <NAME> <TYPE> | -d <GUID | NAME> | -D <[GUID | NAME],...,[GUID | NAME]> | -g <GUID | NAME> | -l | -r <[GUID]> | -s <GUID |
#        NAME> <PROPERTY_NO.> <VALUE>
# Backup destination management
#  -c,--create <NAME> <TYPE>                                   Create backup destination (type = ["filesystem", "netbackup", "networker",
#                                                              "s3", "swift", "isp", "azure", "gcs", "avamar"])
#  -d,--delete <GUID | NAME>                                   Delete backup destination
#  -D,--remove-old-backups <[GUID | NAME],...,[GUID | NAME]>   Remove old backups
#  -g,--details <GUID | NAME>                                  Show backup destination details
#  -l,--list                                                   List backup destinations
#  -r,--reinit <[GUID]>                                        Reinitialize backup destination
#  -s,--set <GUID | NAME> <PROPERTY_NO.> <VALUE>               Modify backup destination
```

### Setting up parameters for backup destinations

In general `vprotect bd -s <GUID> <PROPERTY_NO.> <VALUE>` command sets value of property with the given number of BD with `GUID`. Property numbers are returned in detailed view of each BD (fields obviously are different for each backup provider). After you create backup destination, show default values with `-g`. Then use property numbers (first number in the property/value line of the detailed view).

Retention time settings are interpreted in days (just give a number without any additional suffixes).

There are however some mode/type fields that require a string to be typed in the correct format:

1. Amazon S3 - `Backup mode` - must be either:
   * `SINGLE_BUCKET` - single bucket for all VMs
   * `ONE_BUCKET_PER_VM` - separate bucket for each VM (note that default limit is 100 buckets in Amazon S3)
2. Swift - `Auth method` - authentication method used to authenticate Swift BD:
   * `BASIC`
   * `TEMPAUTH`
   * `KEYSTONE`
3. Time zones must be specified in the format shown in this table: [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)​

### Examples (backup destinations)

*   To list all backup destinations

    ```bash
    vprotect bd -l
    ```
*   To show details of the given HV manager (by GUID) - **note** that each BD has a different set of fields - numbers at the beginning of a line indicate an identifier of a field you want to set from CLI:

    ```bash
    vprotect bd -g 3263b196-056e-4485-9e8f-932798b58eb3
    <!-- Property                                                                   Value
    ------------------------------------------------------------  ------------------------------------

    GUID                                                                       bb0524fe-40a1-4ca3-bbc9-7f0be8ac73cc
    Node configs                                                               1
    Type                                                                       FILESYSTEM
    Total available space                                                      181 GiB
    Total used space                                                           9,1 GiB
    1. Name                                                                    backup
    2. Pre-access CMD exec. enabled                                            false
    3. Pre-access CMD                                                          []
    4. Post-access CMD exec. enabled                                           false
    5. Post-access CMD                                                         []
    6. Default                                                                 false
    7. Retention (full) - keep last N backups                                  4
    8. Retention (full) - keep newer than                                      30d
    9. Retention (inc.) - keep last N backups                                  30
    10. Retention (inc.) - keep newer than                                     30d
    11. Paths                                                                  [/backup]
    12. Deduplication enabled                                                  false
    13. Deduplication device                                                    -
    14. Deduplicated filesystem mount point (set as 'default' to use BD path)  /backup
    15. Deduplication volume used space threshold percentage                    -
    16. Encryption enabled -->
    ```
*   Remember that to use a BD you need to create a new entry of a given type and then configure its properties (example for IBM Spectrum Protect \[ISP], assume that GUID returned by the first command was `bb74ef6c-f6de-4783-bfa7-70fc2376fb08` ):

    ```bash
    vprotect bd -c MyTSM isp
    vprotect bd -g bb74ef6c-f6de-4783-bfa7-70fc2376fb08
    <!-- Property                                   Value
    -----------------------------------------  ------------------------------------

    GUID                                       bb74ef6c-f6de-4783-bfa7-70fc2376fb08
    Node configs                               1
    Type                                       ISP
    Total available space                      -
    Total used space                           0 B
    1. Name                                    IBM Spectrum Protect
    2. Pre-access CMD exec. enabled            false
    3. Pre-access CMD                          []
    4. Post-access CMD exec. enabled           false
    5. Post-access CMD                         []
    6. Default                                 false
    7. Retention (full) - keep last N backups  4
    8. Retention (full) - keep newer than      30d
    9. Retention (inc.) - keep last N backups  30
    10. Retention (inc.) - keep newer than     30d
    11. dsm.opt file path                      /opt/vprotect/dsm.opt
    12. Node name                              vprotect
    13. Node password                          ***
    14. Time zone                              Europe/Sarajevo
    15. Backup progress refresh rate           20
    16. Restore progress refresh rate          20 -->
    ```

    Now set the properties:

    * retention - full - 4 versions / 30 days
    * retention - incremental - 28 versions / 30 days
    * ISP node name
    * ISP node password
    * ISP server time zone

    ```bash
    vprotect bd -s c1d7fa34-e558-4a1c-af1f-46e88da7bcf5 2 4
    vprotect bd -s c1d7fa34-e558-4a1c-af1f-46e88da7bcf5 3 30
    vprotect bd -s c1d7fa34-e558-4a1c-af1f-46e88da7bcf5 4 28
    vprotect bd -s c1d7fa34-e558-4a1c-af1f-46e88da7bcf5 5 30
    vprotect bd -s c1d7fa34-e558-4a1c-af1f-46e88da7bcf5 7 vprotect
    vprotect bd -s c1d7fa34-e558-4a1c-af1f-46e88da7bcf5 8 vpr0tectPass
    vprotect bd -s c1d7fa34-e558-4a1c-af1f-46e88da7bcf5 9 Europe/Warsaw
    ```

## HV managers (oVirt/RHV/Oracle VM/Nutanix/Kubernetes)

Hypervisor manager management module is used to add, remove hypervisor managers (currently only oVirt and RHV managers) and invoke indexing task. Indexing tasks gathers information about hypervisors and VMs running in the managed environment and updates their location if the VM has been moved to the different hypervisor.

To manage HV managers in the system used`vprotect hvm` sub-command.

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> If you're using RHV/oVirt/Oracle VM/Nutanix/Kubernetes then hypervisors will be detected automatically as a part of the index task. So there is no need to define every hypervisor manually as they will be detected automatically.
{% endhint %}

```bash
vprotect hvm
# Incorrect syntax: Missing required option: [-c Create hypervisor manager (type = ["rhev", "rhv", "ovm", "nutanix", "openstack"]), -d Delete hypervisor manager, -e Set export/import mode for HV manager, -g Show HV manager details, -l List hypervisor managers, -L List hypervisors managed by hypervisor manager, -m Modify hypervisor manager, -n Set node config for hypervisor, -sC Modify hypervisor manager configuration, -s Index inventory on hypervisor manager, -u Set user/password or access key/secret key, -V List VMs managed by hypervisor manager, -sK Set SSH key path]

# usage: hvm -c <URL | ACCOUNT_ID> <TYPE> | -d <GUID | HOST> | -e <GUID | HOST> <DEFAULT|DISK_ATTACHMENT|DISK_IMAGE_TRANSFER|SSH_TRANSFER> | -g <GUID | HOST> | -l | -L <GUID | HOST> | -m <GUID | HOST> <URL> | -n <GUID | HOST> <NODE_CONFIG_GUID | NODE_CONFIG_NAME> | -s <GUID | HOST> |
#        -sC <GUID> <PROPERTY_NO.> <VALUE | "MAPPING1=VALUE1;MAPPING2=VALUE2"> | -sK <GUID> <SSH_KEYPATH> | -u <GUID | HOST> <USER/ACCESS_KEY> <PASSWORD/SECRET_KEY> | -V <GUID | HOST>
# Hypervisor manager management
#  -c,--create <URL | ACCOUNT_ID> <TYPE>                                                                  Create hypervisor manager (type = ["rhev", "rhv", "ovm", "nutanix", "openstack"])
#  -d,--delete <GUID | HOST>                                                                              Delete hypervisor manager
#  -e,--set-export-import-mode <GUID | HOST> <DEFAULT|DISK_ATTACHMENT|DISK_IMAGE_TRANSFER|SSH_TRANSFER>   Set export/import mode for HV manager
#  -g,--details <GUID | HOST>                                                                             Show HV manager details
#  -l,--list                                                                                              List hypervisor managers
#  -L,--list-hvs <GUID | HOST>                                                                            List hypervisors managed by hypervisor manager
#  -m,--modify <GUID | HOST> <URL>                                                                        Modify hypervisor manager
#  -n,--set-node-config <GUID | HOST> <NODE_CONFIG_GUID | NODE_CONFIG_NAME>                               Set node config for hypervisor
#  -s,--sync <GUID | HOST>                                                                                Index inventory on hypervisor manager
#  -sC,--configuration <GUID> <PROPERTY_NO.> <VALUE | "MAPPING1=VALUE1;MAPPING2=VALUE2">                  Modify hypervisor manager configuration
#  -sK,--set-ssh-key-path <GUID> <SSH_KEYPATH>                                                            Set SSH key path
#  -u,--credentials <GUID | HOST> <USER/ACCESS_KEY> <PASSWORD/SECRET_KEY>                                 Set user/password or access key/secret key
#  -V,--list-vms <GUID | HOST>
```

### Examples (HV managers)

*   To list all hypervisor managers

    ```bash
    vprotect hvm -l
    ```
*   To show details of the given HV manager (by GUID)

    ```bash
    vprotect hvm -g 4c999c85-e223-4df3-9c40-7b0115234c8c
    ```
*   To index VMs and hypervisors on the given HV manager:

    ```bash
    vprotect hvm -s 4c999c85-e223-4df3-9c40-7b0115234c8c
    ```
* To create a HV manager you need to execute the following commands:
  *   Create HV manger entry with given type:

      ```bash
      vprotect hvm -c https://dovirt-m.lab.local/ovirt-engine/api/v3 rhev
      ```
  *   Use GUID returned to set credentials:

      ```bash
      vprotect hvm -u 4c999c85-e223-4df3-9c40-7b0115234c8c admin@internal password
      ```
  *   By default current node configuration is used for created HV manager - you may change it with this command (first HV GUID, then node configuration GUID):

      ```bash
      vprotect hvm -n 4c999c85-e223-4df3-9c40-7b0115234c8c e2673e8f-66fc-4e9f-aaef-20958c4c2b01
      ```

      Hypervisors connected to the HV manager will have node configuration of the HV manager assigned by default. For backup export always node configuration assigned to the HV is used.

## Hypervisors

The Hypervisor management module is used to add, remove hypervisors and invoke indexing tasks. Indexing tasks gather information about VMs running on the hypervisor and update their location if the VM has been moved within the pool.

To manage hypervisors in the system used `vprotect hv` sub-command.

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> If you're using RHV/oVirt/Oracle VM then hypervisors will be detected automatically as a part of the index task. So there is no need to define OVM hypervisors and for RHV/oVirt KVM hosts will be detected automatically.
{% endhint %}

```bash
vprotect hv
# Incorrect syntax: Missing required option: [-sC Modify hypervisor configuration, -c Create hypervisor (type = ["citrix", "nutanix", "proxmox", "ovm", "kvm", "xen"]), -s Synchronize inventory with hypervisor, -d Delete hypervisor, -nC Set node config for hypervisor, -e Set export/import mode for hypervisor, -u Set user/password, -g Show hypervisor details, -sK Set SSH key path, -l List hypervisors, -L List VMs for hypervisor, -m Modify hypervisor]

# usage: hv -c <HOST> <TYPE> | -d <GUID | HOST> | -e <GUID | HOST> <DEFAULT|VM_IMAGE_PLUS_INCREMENTAL_DISKS|CHANGED_BLOCK_TRACKING|SSH_TRANSFER|EXPORT_STORAGE_REPO> | -g <GUID | HOST> | -l | -L <GUID | HOST> | -m <GUID | HOST> <NEW_HOST> | -nC <GUID | HOST> <NODE_CONFIG_GUID> | -s
#        <GUID | HOST> | -sC <GUID> <PROPERTY_NO.> <VALUE> | -sK <GUID> <SSH_KEYPATH> | -u <GUID | HOST> <USER> <PASSWORD>

# Hypervisor management
#  -c,--create <HOST> <TYPE>                                                                                                                     Create hypervisor (type = ["citrix", "nutanix", "proxmox", "ovm", "kvm", "xen"])
#  -d,--delete <GUID | HOST>                                                                                                                     Delete hypervisor
#  -e,--set-export-import-mode <GUID | HOST> <DEFAULT|VM_IMAGE_PLUS_INCREMENTAL_DISKS|CHANGED_BLOCK_TRACKING|SSH_TRANSFER|EXPORT_STORAGE_REPO>   Set export/import mode for hypervisor
#  -g,--details <GUID | HOST>                                                                                                                    Show hypervisor details
#  -l,--list                                                                                                                                     List hypervisors
#  -L,--list-vms <GUID | HOST>                                                                                                                   List VMs for hypervisor
#  -m,--modify <GUID | HOST> <NEW_HOST>                                                                                                          Modify hypervisor
#  -nC,--set-node-config <GUID | HOST> <NODE_CONFIG_GUID>                                                                                        Set node config for hypervisor
#  -s,--sync <GUID | HOST>                                                                                                                       Synchronize inventory with hypervisor
#  -sC,--configuration <GUID> <PROPERTY_NO.> <VALUE>                                                                                             Modify hypervisor configuration
#  -sK,--set-ssh-key-path <GUID> <SSH_KEYPATH>                                                                                                   Set SSH key path
#  -u,--credentials <GUID | HOST> <USER> <PASSWORD>                                                                                              Set user/password
```

### Examples (Hypervisors)

*   To list all hypervisors

    ```bash
    vprotect hv -l
    ```
*   To show details of the given hypervisor (by GUID)

    ```bash
    vprotect hv -g c93140b8-a898-4aff-8eef-645587ca8289
    ```
*   To index VMs on the given HV:

    ```bash
    vprotect hv -s c93140b8-a898-4aff-8eef-645587ca8289
    ```
* To create a hypervisor you need to execute the following commands:
  *   Create HV entry with given type:

      ```bash
      vprotect hv -c 1.2.3.4 citrix
      ```
  *   Use GUID returned to set credentials:

      ```bash
      vprotect hv -u a757c6e8-ece0-467b-b912-dfe393d1e421 root password
      ```
  *   By default current node configuration is used for created hypervisor - you may change it with this command (first HV GUID, then node configuration GUID):

      ```bash
      vprotect hv -n a757c6e8-ece0-467b-b912-dfe393d1e421 e2673e8f-66fc-4e9f-aaef-20958c4c2b01
      ```

## Hypervisor clusters

Hypervisor clusters management module enables you to view and remove clusters detected on RHV/oVirt/Nutanix/OVM/XenServer environments.

To view or delete them use `vprotect hc` sub-command.

```bash
vprotect hc
# Incorrect syntax: Missing required option: [-d Delete HV cluster, -l List HV clusters]

# usage: hc -d <GUID> | -l
# Hypervisor cluster management
#  -d,--delete <GUID>                                             Delete HV cluster
#  -l,--list                                                      List HV clusters
#  -sn,--set-name <GUID> <NAME>                                   Change Hypervisor Cluster name
#  -sp,--set-storage-provider <GUID> <STORAGE_PROVIDER_GUID>>     Assign Storage Provider to Hypervisor Cluster. No value unassigns Storage Provider
```

### Examples (Hypervisor clusters)

*   To list all detected clusters:

    ```bash
    vprotect hc -l
    ```
*   To delete a cluster with GUID `107bc87a-9adf-4d6c-b732-345dd06c59e9`:

    ```bash
    vprotect hc -d 107bc87a-9adf-4d6c-b732-345dd06c59e9
    ```

## Hypervisor storage

Hypervisor storage management module enables you to view and remove storage detected on RHV/oVirt/Nutanix/OVM/XenServer environments. You can select storage in the restore dialog box for XenServer/Nutanix and RHV/oVirt (v4) platforms.

To view or delete them used `vprotect hs` sub-command.

```bash
vprotect hs
# Incorrect syntax: Missing required option: [-d Delete HV storage, -l List HV storage]

# usage: hs -d <GUID> | -l
# Hypervisor storage management
#  -d,--delete <GUID>   Delete HV storage
#  -l,--list            List HV storage
```

### Examples (Hypervisor storage)

*   To list all detected storage volumes:

    ```bash
    vprotect hs -l
    ```
*   To delete a storage volume with GUID `6b5aa45a-5436-47cd-82ce-1c4250742323`:

    ```bash
    vprotect hs -d 6b5aa45a-5436-47cd-82ce-1c4250742323
    ```

## Virtual machines

The Virtual machine management module is used to provide information about VMs that has been detected on hypervisors, report the status of the last backup of your VMs (and all backups for a particular VM) and set priority for operations invoked on VM.

To manage VMs in the system used `vprotect vm` sub-command.

VMs are detected automatically during `Index` tasks executed on the HV or HV manager.

```bash
vprotect vm
# Incorrect syntax: Missing required option: [-A Assign VM to the policy, -D List detected VM disks, -xC Set pre-snapshot CMD as semi-colon-separated string, i.e. "cmd;-a;-b", -wb Acknowledge warnings related to the backup, -L List backups of the VM, -xE Set pre-snapshot CMD exec enabled (1) / disabled (0), -rvS Revert snapshot, -cS Create VM snapshot, -se Set handling for pre-snap standard error. Values: DONT_IGNORE, IGNORE_WITH_WARNING, IGNORE_WITHOUT_WARNING, -S List managed VM snapshots, -T List tasks related to the VM, -si Set pre-snap ignored command exit codes e.g. '15, 101-150' or '*', -gb Show backup details, -d Delete VM, -g Show virtual machine details, -XC Set post-snapshot CMD as semi-colon-separated string, i.e. "cmd;-a;-b", -l List VMs, -XE Set post-snapshot CMD exec enabled (1) / disabled (0), -sC Set SSH access credentials, -sE Set handling for post-snap standard error. Values: DONT_IGNORE, IGNORE_WITH_WARNING, IGNORE_WITHOUT_WARNING, -sH Set SSH access host/port, -sI Set post-snap ignored command exit codes e.g. '15, 101-150' or '*', -w Acknowledge all backup warnings related to the VM, -sK Set SSH key path, -rmS Remove old snapshots, -eD Exclude disk from backup excluded (1) / included (0)]

# usage: vm -A <GUID> <VM_POLICY_GUID> | -cS <GUID> <RULE_GUID> <PRIORITY> | -D <GUID> | -d <GUID> | -eD <DISK_GUID> <0|1> | -g <<VM_GUID>> | -gb <BACKUP_GUID> | -L <GUID> | -l | -rmS <VM_GUID,...,VM_GUID> | -rvS <SNAPSHOT_GUID> | -S <GUID> | -sC <GUID> <SSH_USER> <SSH_PASS> | -se
#        <GUID> <HANDLING> | -sE <GUID> <HANDLING> | -sH <GUID> <SSH_HOST> <SSH_PORT> | -si <GUID> <IGNORED_EXIT_CODES> | -sI <GUID> <IGNORED_EXIT_CODES> | -sK <GUID> <SSH_KEYPATH> | -T <GUID> | -w <GUID> | -wb <BACKUP_GUID> | -xC <GUID> <CMD_STRING> | -XC <GUID> <CMD_STRING> | -xE
#        <GUID> <0|1> | -XE <GUID> <0|1>

# Virtual machine management
#  -A,--assign-vm-policy <GUID> <VM_POLICY_GUID>              Assign VM to the policy
#  -cS,--create-snapshot <GUID> <RULE_GUID> <PRIORITY>        Create VM snapshot
#  -D,--list-disks <GUID>                                     List detected VM disks
#  -d,--delete <GUID>                                         Delete VM
#  -eD,--exclude-disk <DISK_GUID> <0|1>                       Exclude disk from backup excluded (1) / included (0)
#  -dnp,--delete-non-present <[PROJECT_UUID]>                 Delete non-present Virtual Machines. Project UUID is optional
#  -g,--details <<VM_GUID>>                                   Show virtual machine details
#  -gb,--show-backup-details <BACKUP_GUID>                    Show backup details
#  -L,--list-backups <GUID>                                   List backups of the VM
#  -l,--list                                                  List VMs
#  -rmS,--remove-snapshot <VM_GUID,...,VM_GUID>               Remove old snapshots
#  -rvS,--revert-snapshot <SNAPSHOT_GUID>                     Revert snapshot
#  -S,--list-snapshots <GUID>                                 List managed VM snapshots
#  -sC,--set-ssh-credentials <GUID> <SSH_USER> <SSH_PASS>     Set SSH access credentials
#  -se,--set-pre-std-error-out <GUID> <HANDLING>              Set handling for pre-snap standard error. Values: DONT_IGNORE, IGNORE_WITH_WARNING, IGNORE_WITHOUT_WARNING
#  -sE,--set-post-std-error-out <GUID> <HANDLING>             Set handling for post-snap standard error. Values: DONT_IGNORE, IGNORE_WITH_WARNING, IGNORE_WITHOUT_WARNING
#  -sH,--set-ssh-host <GUID> <SSH_HOST> <SSH_PORT>            Set SSH access host/port
#  -si,--set-pre-ignored-codes <GUID> <IGNORED_EXIT_CODES>    Set pre-snap ignored command exit codes e.g. '15, 101-150' or '*'
#  -sI,--set-post-ignored-codes <GUID> <IGNORED_EXIT_CODES>   Set post-snap ignored command exit codes e.g. '15, 101-150' or '*'
#  -sK,--set-ssh-key-path <GUID> <SSH_KEYPATH>                Set SSH key path
#  -T,--list-tasks <GUID>                                     List tasks related to the VM
#  -w,--ack-all-backup-warnings <GUID>                        Acknowledge all backup warnings related to the VM
#  -wb,--ack-backup-warnings <BACKUP_GUID>                    Acknowledge warnings related to the backup
#  -xC,--set-pre-snap-cmd <GUID> <CMD_STRING>                 Set pre-snapshot CMD as semi-colon-separated string, i.e. "cmd;-a;-b"
#  -XC,--set-post-snap-cmd <GUID> <CMD_STRING>                Set post-snapshot CMD as semi-colon-separated string, i.e. "cmd;-a;-b"
#  -xE,--set-pre-snap-cmd-exec-enabled <GUID> <0|1>           Set pre-snapshot CMD exec enabled (1) / disabled (0)
#  -XE,--set-post-snap-cmd-exec-enabled <GUID> <0|1>          Set post-snapshot CMD exec enabled (1) / disabled (0)
```

### Examples (Virtual machines)

*   To list all VMs

    ```bash
    vprotect vm -l
    ```
*   To show details of the given VM (by GUID)

    ```bash
    vprotect vm -g 0f36f40c-6427-4035-9f2b-1ead6aca3597
    ```
*   To add VM (first GUID) to the given policy (second GUID):

    ```bash
    vprotect vm -A 0f36f40c-6427-4035-9f2b-1ead6aca3597 3afcd507-a4f5-484d-8d34-53c73d7a5809
    ```
*   To show backup history of a VM with given GUID:

    ```bash
    vprotect vm -L 0f36f40c-6427-4035-9f2b-1ead6aca3597
    ```
*   To create snapshot of a VM with given GUID (VM must have snapshot policy already assigned):

    ```bash
    vprotect vm -cS 0f36f40c-6427-4035-9f2b-1ead6aca3597
    ```

## Storage backup management

This module is responsible for managing storage instances and actions related to backups/schedules/policies etc.

```bash
vprotect st
# Incorrect syntax: Missing required option:
# [-A Assign Storage to the policy, -a Assign Storage to the snapshot policy,
#  -d Delete Storage, -g Show Storage details, -wb Acknowledge warnings related
#  to the backup, -xC Set pre-snapshot CMD as semi-colon-separated string,
#  i.e. "cmd;-a;-b", -XC Set post-snapshot CMD as semi-colon-separated string,
#  i.e. "cmd;-a;-b", -l List Storages, -L List backups of the Storage,
#  -sC Set SSH access credentials, -se Set handling for pre-snap standard error.
#  Values: DONT_IGNORE, IGNORE_WITH_WARNING, IGNORE_WITHOUT_WARNING,
#  -sE Set handling for post-snap standard error. Values: DONT_IGNORE,
#  IGNORE_WITH_WARNING, IGNORE_WITHOUT_WARNING, -s Modify Storage configuration,
#  -T List tasks related to the Storage, -w Acknowledge all backup warnings
#  related to the Storage, -gb Show backup details]

# usage: st -A <GUID> <STORAGE_POLICY_GUID> | -a <GUID> <SNAPSHOT_POLICY_GUID> |
#   -d <GUID> | -g <GUID> | -gb <BACKUP_GUID> | -l | -L <GUID> |
#   -s <GUID> <PROPERTY_NO.> <VALUE> | -sC <GUID> <SSH_USER> <SSH_PASS> |
#   -se <GUID> <HANDLING> | -sE <GUID> <HANDLING> |-T <GUID> | -w <GUID> |
#   -wb <BACKUP_GUID> | -xC <GUID> <CMD_STRING> | -XC <GUID> <CMD_STRING>
# Storage management
#  -A,--assign-storage-policy <GUID> <STORAGE_POLICY_GUID>
#     #Assign Storage to the policy
#  -a,--assign-snapshot-policy <GUID> <SNAPSHOT_POLICY_GUID>
#     #Assign Storage to the snapshot policy
#  -d,--delete <GUID>
#     #Delete Storage
#  -g,--details <GUID>
#     #Show Storage details
#  -gb,--show-backup-details <BACKUP_GUID>
#     #Show backup details
#  -l,--list
#     #List Storages
#  -L,--list-backups <GUID>
#     #List backups of the Storage
#  -s,--configuration <GUID> <PROPERTY_NO.> <VALUE>
#     #Modify Storage configuration
#  -sC,--set-ssh-credentials <GUID> <SSH_USER> <SSH_PASS>
#     #Set SSH access credentials
#  -se,--set-pre-std-error-out <GUID> <HANDLING>
#     #Set handling for pre-snap standard error. Values: DONT_IGNORE,
#     #IGNORE_WITH_WARNING, IGNORE_WITHOUT_WARNING
#  -sE,--set-post-std-error-out <GUID> <HANDLING>
#     #Set handling for post-snap standard error. Values: DONT_IGNORE,
#     #IGNORE_WITH_WARNING, IGNORE_WITHOUT_WARNING
#  -T,--list-tasks <GUID>
#     #List tasks related to the Storage
#  -w,--ack-all-backup-warnings <GUID>
#     #Acknowledge all backup warnings related to the Storage
#  -wb,--ack-backup-warnings <BACKUP_GUID>
#     #Acknowledge warnings related to the backup
#  -xC,--set-pre-snap-cmd <GUID> <CMD_STRING>
#     #Set pre-snapshot CMD as semi-colon-separated string, i.e. "cmd;-a;-b"
#  -XC,--set-post-snap-cmd <GUID> <CMD_STRING>
#     #Set post-snapshot CMD as semi-colon-separated string, i.e. "cmd;-a;-b"
```

### Examples (Storage backup management)

## Storage pool management

This small module allows us to list and deleting inventoried storage pools.

```bash
vprotect stpool
# Incorrect syntax: Missing required option: [-d Delete Storage Pool,
# -l List Storage Pools]

# usage: stpool -d <GUID> | -l
# Storage pool management
#  -d,--delete <GUID>        Delete Storage Pool
#  -l,--list                 List Storage Pools
```

### Examples (Storage pool management)

To list storage pools

```bash
vprotect stpool -l

#                 GUID                   Name                     UUID                   Storage Provider
# ------------------------------------  -------  --------------------------------------  ----------------
# b1171aba-aeb3-4e10-84dd-f3e3c0dc3235  backups  537e00c8-620d-4256-8d6c-e5e031327caa_1  last-ceph
# 86f41229-6f13-41b3-b1ce-c5841df7b4c7  images   537e00c8-620d-4256-8d6c-e5e031327caa_4  last-ceph
# 55832390-1779-483b-8023-88bb9a79b6ed  vms      537e00c8-620d-4256-8d6c-e5e031327caa_3  last-ceph
# ff3a9f65-0b5f-4a78-8b97-b883cb971f81  volumes  537e00c8-620d-4256-8d6c-e5e031327caa_2  last-ceph
```

## Storage providers management

This module is responsible for managing the storage provider's infrastructure. So performing tasks such as adding/removing / inventorying, etc.

```bash
vprotect stprovider
# Incorrect syntax: Missing required option: [-sC Modify Storage Provider configuration, -c Create Storage Provider, -s Synchronize inventory with Storage Provider, -d Delete Storage Provider, -u Set user/password, -nC Set node config for Storage Provider, -g Show Storage Providers details, -h Set host for Storage Provider, -l List Storage Providers, -L List Storages for Storage Provider, -n Set node for Storage Provider]

# usage: stprovider -c <HOST> <TYPE> | -d <GUID> | -g <GUID> | -h <GUID> <HOST> | -l | -L <GUID> | -n <GUID> <NODE_GUID> | -nC <GUID> <NODE_CONFIG_GUID> | -s <GUID> | -sC <GUID> <PROPERTY_NO.> <VALUE> | -u <GUID> <USER> <PASSWORD>
# +Storage provider management
#  -c,--create <HOST> <TYPE>                           Create Storage Provider
#  -d,--delete <GUID>                                  Delete Storage Provider
#  -g,--details <GUID>                                 Show Storage Providers details
#  -h,--set-host <GUID> <HOST>                         Set host for Storage Provider
#  -l,--list                                           List Storage Providers
#  -L,--list-storages <GUID>                           List Storages for Storage Provider
#  -n,--set-node <GUID> <NODE_GUID>                    Set node for Storage Provider
#  -nC,--set-node-config <GUID> <NODE_CONFIG_GUID>     Set node config for Storage Provider
#  -s,--sync <GUID>                                    Synchronize inventory with Storage Provider
#  -sC,--configuration <GUID> <PROPERTY_NO.> <VALUE>   Modify Storage Provider configuration
#  -u,--credentials <GUID> <USER> <PASSWORD>           Set user/password
```

### Examples (Storage providers management)

## VM backup policies

Virtual machine backup policies management module is used to define backup policies of VMs. You can assign different backup priorities for a policy when the scheduler invokes a backup task. You need first to define a VM policy and then add VMs to it. VM can belong only to a single backup policy.

To manage VM policies in the system use `vprotect vmpolicy` sub-command.

VMs are assigned automatically to the policy only if VM has no policy assigned already. If an automatic assignment has been turned on for a policy and either name of the VM matches the regular expression, or tag-detected (Citrix/oVirt/RHV/Oracle VM) matches tag defined for the policy, VM is assigned to the policy, and all schedules for a policy will also be automatically invoked for this VM.

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> it is important to assign a backup destination for a policy (required for a node to know where to store backups).
{% endhint %}

```bash
vprotect vmpolicy
# Required option: [-rR Remove auto-assignment RE, -rT Remove auto-assignment tag, -aC Set auto-assignment HV clusters, -b Set backup destination for the VM policy, -c Create a new policy, -d Delete a policy, -g Show details, -l List policies, -L List VMs in the policy, -aM Set auto-assignment mode, -m Modify policy, -aN Set auto-removal of non-present VMs flag, -p Set policy's backup task priority (0-100, 50 = default), -aR Add auto-assignment RE, -aT Add auto-assignment tag, -S List schedules for the policy, -s Set schedules for the VM policy, -U Unassign VMs from the policy, -V Assign VMs to the policy]

# usage: vmpolicy -aC <GUID > <[HV_CLUSTER_GUID,...,HV_CLUSTER_GUID]> | -aM <GUID> <DISABLED|ASSIGN_ONLY|ASSIGN_AND_REMOVE> | -aN <GUID> <0|1> | -aR <GUID>
#        <inc|exc> <REG_EXP> | -aT <GUID> <inc|exc> <TAG> | -b <GUID> <BD_GUID | BD_NAME>> | -c <NAME> | -d <GUID> | -g <GUID> | -l | -L <GUID> | -m <GUID>
#        <NAME> | -p <GUID> <PRIORITY> | -rR <GUID> <inc|exc> <REG_EXP> | -rT <GUID> <inc|exc> <TAG> | -S <GUID> | -s <GUID> <SCHED_GUID,...,SCHED_GUID> | -U
#        <VM_GUID,...,VM_GUID> | -V <GUID> <VM_GUID,...,VM_GUID>
# VM backup policy management
#  -aC,--set-auto-assign-hv-clusters <GUID > <[HV_CLUSTER_GUID,...,HV_CLUSTER_GUID]>   Set auto-assignment HV clusters
#  -aM,--set-auto-assign-mode <GUID> <DISABLED|ASSIGN_ONLY|ASSIGN_AND_REMOVE>          Set auto-assignment mode
#  -aN,--set-auto-remove-non-present <GUID> <0|1>                                      Set auto-removal of non-present VMs flag
#  -aR,--add-auto-assign-re <GUID> <inc|exc> <REG_EXP>                                 Add auto-assignment RE
#  -aT,--add-auto-assign-tag <GUID> <inc|exc> <TAG>                                    Add auto-assignment tag
#  -b,--set-backup-destination <GUID> <BD_GUID | BD_NAME>>                             Set backup destination for the VM policy
#  -c,--create <NAME>                                                                  Create a new policy
#  -d,--delete <GUID>                                                                  Delete a policy
#  -g,--details <GUID>                                                                 Show details
#  -l,--list                                                                           List policies
#  -L,--list-vms <GUID>                                                                List VMs in the policy
#  -m,--modify <GUID> <NAME>                                                           Modify policy
#  -p,--set-priority <GUID> <PRIORITY>                                                 Set policy's backup task priority (0-100, 50 = default)
#  -rR,--remove-auto-assign-re <GUID> <inc|exc> <REG_EXP>                              Remove auto-assignment RE
#  -rT,--remove-auto-assign-tag <GUID> <inc|exc> <TAG>                                 Remove auto-assignment tag
#  -S,--list-schedules <GUID>                                                          List schedules for the policy
#  -s,--set-schedules <GUID> <SCHED_GUID,...,SCHED_GUID>                               Set schedules for the VM policy
#  -U,--unassign-vms <VM_GUID,...,VM_GUID>                                             Unassign VMs from the policy
#  -V,--assign-vms <GUID> <VM_GUID,...,VM_GUID>                                        Assign VMs to the policy
```

### Examples (VM backup policies)

*   To list all VM policies

    ```bash
    vprotect vmpolicy -l
    ```
*   To show details of the given VM (by GUID)

    ```bash
    vprotect vmpolicy -g 3afcd507-a4f5-484d-8d34-53c73d7a5809
    ```
*   To create a new policy

    ```bash
    vprotect vmpolicy -c "My Policy"
    ```
*   To add `policy1` tag (include) for a policy:

    ```bash
    vprotect vmpolicy -aT 3afcd507-a4f5-484d-8d34-53c73d7a5809 inc policy1
    ```
*   To remove `policy1` tag (include) for a policy:

    ```bash
    vprotect vmpolicy -rT 3afcd507-a4f5-484d-8d34-53c73d7a5809 inc policy1
    ```
*   To set 2 schedules (GUIDs are comma-separated) for a policy (first GUID):

    ```bash
    vprotect vmpolicy -s 3afcd507-a4f5-484d-8d34-53c73d7a5809 391203e3-ad6c-4532-b69c-78b3a5cf4ef5,e4c1c61d-26db-4e41-87cf-2195d5498cde
    ```
*   To set backup destination (you can use name or GUID) for a policy (first GUID):

    ```bash
    vprotect vmpolicy -b 3afcd507-a4f5-484d-8d34-53c73d7a5809 ISP
    ```

## Snapshot management policies for VMs

The snapshot management policies module enables CDM for your VMs and manages their retention. Currently, it is supported for KVM, Citrix, RHV/oVirt/OLVM platforms.

To manage snapshot policies for VMs in the system use `vprotect vm-snappolicy` sub-command.

VMs are assigned automatically to the policy only if VM has no policy assigned already. If an automatic assignment has been turned on for a policy and either name of the VM matches a regular expression, or tag-detected (Citrix/RHV/oVirt/OLVM) matches tag defined for the policy, VM is assigned to the policy, and all schedules for a policy will also be automatically invoked for this VM.

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> Only VMs with assigned snapshot management policy can be a snapshot from the CLI or UI.
{% endhint %}

```bash
vprotect vm-snappolicy
# Required option: [-rR Remove rules from policy, -rT Remove auto-assignment tag, -aC Set auto-assignment HV clusters, -c Create a new policy, -d Delete a policy, -g Show details, -l List policies, -L List VMs in the policy, -aM Set auto-assignment mode, -m Modify policy, -aN Set auto-removal of non-present VMs flag, -p Set policy's backup task priority (0-100, 50 = default), -aR Add new rule to selected policy, -r List rules for policy, -aT Add auto-assignment tag, -U Unassign VMs from the policy, -V Assign VMs to the policy]

# usage: vm-snappolicy -aC <GUID > <[HV_CLUSTER_GUID,...,HV_CLUSTER_GUID]> | -aM <GUID> <DISABLED|ASSIGN_ONLY|ASSIGN_AND_REMOVE> | -aN <GUID> <0|1> | -aR <NAME>
#        <POLICY_GUID> <RETENTION_DAYS> <RETENTION_VERSIONS> | -aT <GUID> <inc|exc> <TAG> | -c <NAME> | -d <GUID> | -g <GUID> | -l | -L <GUID> | -m <GUID>
#        <NAME> | -p <GUID> <PRIORITY> | -r <GUID> | -rR <POLICY_GUID> <RULE_GUID,...,RULE_GUID> | -rT <GUID> <inc|exc> <TAG> | -U <VM_GUID,...,VM_GUID> | -V
#        <GUID> <VM_GUID,...,VM_GUID>
# Snapshot policy management
#  -aC,--set-auto-assign-hv-clusters <GUID > <[HV_CLUSTER_GUID,...,HV_CLUSTER_GUID]>   Set auto-assignment HV clusters
#  -aM,--set-auto-assign-mode <GUID> <DISABLED|ASSIGN_ONLY|ASSIGN_AND_REMOVE>          Set auto-assignment mode
#  -aN,--set-auto-remove-non-present <GUID> <0|1>                                      Set auto-removal of non-present VMs flag
#  -aR,--add-rule <NAME> <POLICY_GUID> <RETENTION_DAYS> <RETENTION_VERSIONS>           Add new rule to selected policy
#  -aT,--add-auto-assign-tag <GUID> <inc|exc> <TAG>                                    Add auto-assignment tag
#  -c,--create <NAME>                                                                  Create a new policy
#  -d,--delete <GUID>                                                                  Delete a policy
#  -g,--details <GUID>                                                                 Show details
#  -l,--list                                                                           List policies
#  -L,--list-vms <GUID>                                                                List VMs in the policy
#  -m,--modify <GUID> <NAME>                                                           Modify policy
#  -p,--set-priority <GUID> <PRIORITY>                                                 Set policy's backup task priority (0-100, 50 = default)
#  -r,--list-rules <GUID>                                                              List rules for policy
#  -rR,--remove-rules <POLICY_GUID> <RULE_GUID,...,RULE_GUID>                          Remove rules from policy
#  -rT,--remove-auto-assign-tag <GUID> <inc|exc> <TAG>                                 Remove auto-assignment tag
#  -U,--unassign-vms <VM_GUID,...,VM_GUID>                                             Unassign VMs from the policy
#  -V,--assign-vms <GUID> <VM_GUID,...,VM_GUID>                                        Assign VMs to the policy
```

### Examples (Snapshot management policies for VMs)

*   To list all snapshot policies

    ```bash
    vprotect vm-snappolicy -l
    ```
*   To show details of the given VM (by GUID)

    ```bash
    vprotect vm-snappolicy -g 3afcd507-a4f5-484d-8d34-53c73d7a5809
    ```
*   To create a new policy

    ```bash
    vprotect vm-snappolicy -c "My Policy"
    ```
*   To add `policy1` tag (include) for a policy:

    ```bash
    vprotect vm-snappolicy -aT 3afcd507-a4f5-484d-8d34-53c73d7a5809 inc policy1
    ```
*   To remove `policy1` tag (include) for a policy:

    ```bash
    vprotect vm-snappolicy -rT 3afcd507-a4f5-484d-8d34-53c73d7a5809 inc policy1
    ```
*   To set 2 schedules (GUIDs are comma-separated) for a policy (first GUID):

    ```bash
    vprotect vm-snappolicy -s 3afcd507-a4f5-484d-8d34-53c73d7a5809 391203e3-ad6c-4532-b69c-78b3a5c
    ```

## Snapshot management policies for storage

To manage snapshot policies for storage in the system used `vprotect storage-snappolicy` sub-command.

Storages are assigned automatically to the policy only if storage has no policy assigned already. If an automatic assignment has been turned on for a policy and the name of the storage matches the regular expression, storage is assigned to the policy, and all schedules for a policy will also be automatically invoked for this storage.

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> only storage with an assigned snapshot management policy can be a snapshot from the CLI or UI.
{% endhint %}

```bash
vprotect storage-snappolicy
# Incorrect syntax: Missing required option: [-rR Remove rules from policy, -c Create a new policy, -d Delete a policy, -g Show details, -l List policies, -aM Set auto-assignment mode, -L List storages in the policy, -m Modify policy, -aN Set auto-removal of non-present VMs flag, -aP Set auto-assignment storage pools, -p Set policy's backup task priority (0-100, 50 = default), -aR Add new rule to selected policy, -r List rules for policy, -S Assign storages to the policy, -U Unassign storages from the policy]

# usage: storage-snappolicy -aM <GUID> <DISABLED|ASSIGN_ONLY|ASSIGN_AND_REMOVE> | -aN <GUID> <0|1> | -aP <GUID > <[STORAGE_POOL_GUID,...,STORAGE_POOL_GUID]> | -aR <NAME> <POLICY_GUID> <RETENTION_DAYS> <RETENTION_VERSIONS> | -c <NAME> | -d <GUID> | -g <GUID> | -l | -L <GUID> | -m
#        <GUID> <NAME> | -p <GUID> <PRIORITY> | -r <GUID> | -rR <POLICY_GUID> <RULE_GUID,...,RULE_GUID> | -S <GUID> <STORAGE_GUID,...,STORAGE_GUID> | -U <STORAGE_GUID,...,STORAGE_GUID>
# +Snapshot policy management for storages
#  -aM,--set-auto-assign-mode <GUID> <DISABLED|ASSIGN_ONLY|ASSIGN_AND_REMOVE>                Set auto-assignment mode
#  -aN,--set-auto-remove-non-present <GUID> <0|1>                                            Set auto-removal of non-present VMs flag
#  -aP,--set-auto-assign-storage-pools <GUID > <[STORAGE_POOL_GUID,...,STORAGE_POOL_GUID]>   Set auto-assignment storage pools
#  -aR,--add-rule <NAME> <POLICY_GUID> <RETENTION_DAYS> <RETENTION_VERSIONS>                 Add new rule to selected policy
#  -c,--create <NAME>                                                                        Create a new policy
#  -d,--delete <GUID>                                                                        Delete a policy
#  -g,--details <GUID>                                                                       Show details
#  -l,--list                                                                                 List policies
#  -L,--list-storages <GUID>                                                                 List storages in the policy
#  -m,--modify <GUID> <NAME>                                                                 Modify policy
#  -p,--set-priority <GUID> <PRIORITY>                                                       Set policy's backup task priority (0-100, 50 = default)
#  -r,--list-rules <GUID>                                                                    List rules for policy
#  -rR,--remove-rules <POLICY_GUID> <RULE_GUID,...,RULE_GUID>                                Remove rules from policy
#  -S,--assign-storages <GUID> <STORAGE_GUID,...,STORAGE_GUID>                               Assign storages to the policy
#  -U,--unassign-storages <STORAGE_GUID,...,STORAGE_GUID>                                    Unassign storages from the policy
```

### Examples (Snapshot management policies for storage)

To list all snapshot policies

```bash
vprotect storage-snappolicy -l
```

*   To show details of the given snapshot policy (by GUID)

    ```bash
    vprotect storage-snappolicy -g 3afcd507-a4f5-484d-8d34-53c73d7a5809
    ```
*   To create a new policy

    ```bash
    vprotect storage-snappolicy -c "My Policy"
    ```
*   To set 2 schedules (GUIDs are comma-separated) for a policy (first GUID):

    ```bash
    vprotect vm-snappolicy -s 3afcd507-a4f5-484d-8d34-53c73d7a5809 \
     391203e3-ad6c-4532-b69c-78b3a5c
    ```

## Schedules

The schedule management module is used to create schedules associated with VMs or groups of VMs. Each schedule defines the days of a week and the hour when the backup tasks should be invoked. Each schedule also defines a time window in which the backup process must start. If the task queue is full and the tasks start after the specified amount of time from the schedule – it will be canceled and marked as failed.

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark>

* Tasks in the queue are run in order from the highest to the lowest priority.
* You can assign multiple schedules if you need backup to be executed at different hours on different days.
* Remember always to assign schedules to VM or VM group – schedule can be assigned only to a single VM or VM group.
{% endhint %}

To manage schedules in the system used `vprotect sched` sub-command.

```bash
vprotect sched
# Incorrect syntax: Missing required option: [-a Set schedule to be active (1) / not active (0), -c <NAME> <VM_BACKUP | SNAPSHOT | APP_BACKUP> <BACKUP_TYPE> <TIME | INTERVAL> <START_TIME | INTERVAL_START_HOUR-INTERVAL_END_HOUR> <DURATION | INTERVAL_FREQUENCY> <everyday | LIST_OF_DAYS_OF_WEEK> <any | FIRST_IN_MONTH | SECOND_IN_MONTH | THIRD_IN_MONTH | FOURTH_IN_MONTH | LAST_IN_MONTH> <any | LIST_OF_MONTHS
#  Create schedule for VM (backup type: FULL / INCREMENTAL), -d Delete schedule, -g Show details, -l List schedules, -m <GUID> <NAME> <TYPE> <TIME | INTERVAL> <START_TIME | INTERVAL_START_HOUR-INTERVAL_END_HOUR> <DURATION | INTERVAL_FREQUENCY> <everyday | LIST_OF_DAYS_OF_WEEK> <any | FIRST_IN_MONTH | SECOND_IN_MONTH | THIRD_IN_MONTH | FOURTH_IN_MONTH | LAST_IN_MONTH> <any | LIST_OF_MONTHS
#  Modify schedule (backup type: FULL / INCREMENTAL)]

# usage: sched -a <arg> | -c <arg> | -d <arg> | -g <arg> | -l | -m <arg>

# Schedule management
#  -a,--set-active <GUID> <0|1>              Set schedule to be active (1) / not active (0)
#  -c,--create     <NAME> <VM_BACKUP | SNAPSHOT | APP_BACKUP> <BACKUP_TYPE> <TIME | INTERVAL> <START_TIME | INTERVAL_START_HOUR-INTERVAL_END_HOUR> <DURATION |
#                  INTERVAL_FREQUENCY> <everyday | LIST_OF_DAYS_OF_WEEK> <any | FIRST_IN_MONTH | SECOND_IN_MONTH | THIRD_IN_MONTH | FOURTH_IN_MONTH | LAST_IN_MONTH> <any | LIST_OF_MONTHS>
#                                            Create schedule for VM (backup type: FULL / INCREMENTAL)
#  -d,--delete <GUID>                        Delete schedule
#  -g,--show-details <GUID>                  Show details
#  -l,--list                                 List schedules
#  -m,--modify <GUID> <NAME> <TYPE> <TIME | INTERVAL> <START_TIME | INTERVAL_START_HOUR-INTERVAL_END_HOUR> <DURATION | INTERVAL_FREQUENCY> <everyday |
#                LIST_OF_DAYS_OF_WEEK> <any | FIRST_IN_MONTH | SECOND_IN_MONTH | THIRD_IN_MONTH | FOURTH_IN_MONTH | LAST_IN_MONTH> <any | LIST_OF_MONTHS>
#                                            Modify schedule (backup type: FULL / INCREMENTAL)
```

### Examples (Schedules)

*   To list all schedules

    ```bash
    vprotect sched -l
    ```
*   To create a full virtual machine backup schedule with a name Schedule1 executed every day at 05:00 with 60 minutes of time window:

    ```bash
    vprotect sched -c Schedule1 VM_BACKUP FULL TIME 05:00 60 everyday any any
    ```
*   To create an incremental virtual machine backup schedule with a name Schedule2 executed every Monday, Wednesday and Friday at 17:00 with 90 minutes of time window:

    ```bash
    vprotect sched -c Schedule2 VM_BACKUP INCREMENTAL TIME 17:00 90 mon,wed,fri any any
    ```

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> Days of the week are provided as a single comma-separated string of short (3-letter) weekday names
{% endhint %}

*   To disable a schedule with GUID `6651787d-9a55-421d-8158-ead80a70a9cb`:

    ```bash
    vprotect sched -a 6651787d-9a55-421d-8158-ead80a70a9cb 0
    ```

## VM backup/restore

This module is used to manage the backup and restore processes. It is also used to list backups of a particular VM.

To invoke backup and restore tasks use `vprotect brvm` sub-command.

```bash
vprotect brvm
# Required option: [-b Backup (full), -B Backup (full) with task priority (0-100, 50 = default), -gL Show file details, -F List file systems, -H Restore the backup to the hypervisor. For KVM mixed volumes please provide storages in form of BF_GUID=STORAGE_ID with files separated by semicolon, i.e. "BF_GUID=STORAGE_ID; BF_GUID2=STORAGE_ID2 ...", -i Backup VM (incremental), -I Backup VM (incremental) with task priority (0-100, 50 = default), -l List backups, -L List backup files, -M Restore the backup to the hypervisor manager, -r Restore the backup, -T List tasks related to the backup, -gb Show backup details]

# usage: brvm -b <GUID> <BP_GUID | BP_NAME> | -B <GUID> <BP_GUID | BP_NAME> <PRIORITY> | -F <GUID> | -gb <BACKUP_GUID> | -gL <BACKUP_FILE_GUID> | -H <GUID>
#        <HV_GUID | HV_HOST> <STORAGE_ID> | -i <VM_GUID> <BP_GUID | BP_NAME> | -I <VM_GUID> <BP_GUID | BP_NAME> <PRIORITY> | -l | -L <GUID> | -M <GUID>
#        <HVM_GUID | HVM_HOST> <STORAGE_ID> <[CLUSTER_ID]> | -r <GUID> <NODE_GUID | NODE_NAME> <DIRECTORY> | -T <GUID>
# VM backup & restore
#  -b,--backup <GUID> <BP_GUID | BP_NAME>                                         Backup (full)
#  -B,--backup-with-priority <GUID> <BP_GUID | BP_NAME> <PRIORITY>                Backup (full) with task priority (0-100, 50 = default)
#  -F,--list-file-systems <GUID>                                                  List file systems
#  -gb,--show-backup-details <BACKUP_GUID>                                        Show backup details
#  -gsi,--show-backup-status-info <BACKUP_GUID>                                   Show backup status info
#  -gL,--show-files-details <BACKUP_FILE_GUID>                                    Show file details
#  -H,--restore-to-hv <GUID> <HV_GUID | HV_HOST> <STORAGE_ID>                     Restore the backup to the hypervisor. For KVM mixed volumes please provide
#                                                                                 storages in form of BF_GUID=STORAGE_ID with files separated by semicolon, i.e. "BF_GUID=STORAGE_ID; BF_GUID2=STORAGE_ID2 ..."
#  -i,--backup-inc <VM_GUID> <BP_GUID | BP_NAME>                                  Backup VM (incremental)
#  -I,--backup-inc-with-priority <VM_GUID> <BP_GUID | BP_NAME> <PRIORITY>         Backup VM (incremental) with task priority (0-100, 50 = default)
#  -l,--list                                                                      List backups
#  -L,--list-files <GUID>                                                         List backup files
#  -M,--restore-to-hvm <GUID> <HVM_GUID | HVM_HOST> <STORAGE_ID> <[CLUSTER_ID]>   Restore the backup to the hypervisor manager
#  -r,--restore <GUID> <NODE_GUID | NODE_NAME> <DIRECTORY>                        Restore the backup
#  -T,--list-tasks <GUID>                                                         List tasks related to the backup
```

### Examples (VM backup/restore)

*   To list all backups and their status:

    ```bash
    vprotect brvm -l
    ```
*   To show backups of a particular VM:

    ```bash
    vprotect vm -L 0f36f40c-6427-4035-9f2b-1ead6aca3597
    ```
*   To show files that a specific backup consists of:

    ```bash
    vprotect brvm -L 4f1c7907-72e9-4797-8470-3f1fbb081751
    ```
*   To show detected file systems in specific backup:

    ```bash
    vprotect brvm -F 4f1c7907-72e9-4797-8470-3f1fbb081751
    ```
*   To create a full backup of a VM and store it in backup destination set to rule called `MyTSM`

    ```bash
    vprotect brvm -b 0f36f40c-6427-4035-9f2b-1ead6aca3597 MyTSM
    ```
*   To restore a full backup with given GUID on the current node (`this`) to the `/vprotect_data`

    ```bash
    vprotect brvm -r 2132182d-e9ab-4478-a1db-48222b0e515b this /vprotect_data
    ```
*   To create an incremental backup (Citrix only) of a VM and store it in backup destination called `MyTSM`

    ```bash
    vprotect brvm -i 0f36f40c-6427-4035-9f2b-1ead6aca3597 MyTSM
    ```
*   To restore VM backup (first GUID) to the hypervisor (second GUID - Citrix XenServer only) and specific storage

    ```bash
    vprotect brvm -H 2132182d-e9ab-4478-a1db-48222b0e515b c93140b8-a898-4aff-8eef-645587ca8289 "Local storage"
    ```

## Storage backup/restore

This module is used to manage the backup and restore process of storage providers.

To invoke backup and restore tasks use `vprotect brst` sub-command.

```bash
vprotect brst
# Incorrect syntax: Missing required option: [-b Backup (full), -B Backup (full) with task priority (0-100, 50 = default), -r Restore the backup, -S Restore the storage to the storage provider., -T List tasks related to the backup, -gL Show file details, -i Backup STORAGE (incremental), -I Backup STORAGE (incremental) with task priority (0-100, 50 = default), -gb Show backup details, -l List backups, -L List backup files]

# usage: brst -b <GUID> <BP_GUID | BP_NAME> | -B <GUID> <BP_GUID | BP_NAME> <PRIORITY> | -gb <BACKUP_GUID> | -gL <BACKUP_FILE_GUID> | -i <STORAGE_GUID> <BP_GUID | BP_NAME> | -I <STORAGE_GUID> <BP_GUID | BP_NAME> <PRIORITY> | -l | -L <GUID> | -r <GUID> <DIRECTORY> | -S <GUID>
#        <STORAGE_PROVIDER_GUID | STORAGE_PROVIDER_NAME> <RESTORE_PATH> | -T <GUID>
# Storage backup & restore
#  -b,--backup <GUID> <BP_GUID | BP_NAME>                                                                   Backup (full)
#  -B,--backup-with-priority <GUID> <BP_GUID | BP_NAME> <PRIORITY>                                          Backup (full) with task priority (0-100, 50 = default)
#  -gb,--show-backup-details <BACKUP_GUID>                                                                  Show backup details
#  -gL,--show-files-details <BACKUP_FILE_GUID>                                                              Show file details
#  -i,--backup-inc <STORAGE_GUID> <BP_GUID | BP_NAME>                                                       Backup STORAGE (incremental)
#  -I,--backup-inc-with-priority <STORAGE_GUID> <BP_GUID | BP_NAME> <PRIORITY>                              Backup STORAGE (incremental) with task priority (0-100, 50 = default)
#  -l,--list                                                                                                List backups
#  -L,--list-files <GUID>                                                                                   List backup files
#  -r,--restore <GUID> <DIRECTORY>                                                                          Restore the backup
#  -S,--restore-to-storage-provider <GUID> <STORAGE_PROVIDER_GUID | STORAGE_PROVIDER_NAME> <RESTORE_PATH>   Restore the storage to the storage provider.
#  -T,--list-tasks <GUID>                                                                                   List tasks related to the backup
```

### Examples (Storage backup/restore)

*   To list all backups and their status:

    ```bash
    vprotect brst -l
    ```
*   To show backups of a particular storage:

    ```bash
    vprotect br -L 0f36f40c-6427-4035-9f2b-1ead6aca3597
    ```
*   To show files that a specific backup consists of:

    ```bash
    vprotect brst -L 4f1c7907-72e9-4797-8470-3f1fbb081751
    ```
*   To create a full backup of a storage and store it in backup destination called `MyTSM`

    ```bash
    vprotect brst -b 0f36f40c-6427-4035-9f2b-1ead6aca3597 MyTSM
    ```
*   To restore a full backup with given GUID on the current node (`this`) to the `/vprotect_data`

    ```bash
    vprotect brst \
    -r 2132182d-e9ab-4478-a1db-48222b0e515b this /vprotect_data
    ```
*   To create an incremental backup of a storage and store it in backup destination called `MyTSM`

    ```bash
    vprotect brst -i 0f36f40c-6427-4035-9f2b-1ead6aca3597 MyTSM
    ```

## Mounted backups

The Mounted backup management module is used to mount and unmounts backups on the given node. This feature is currently supported for RHV/oVirt/OVM VMs. Each mounted backup can be mounted automatically (auto-detection of mount points within a single root or manually with separate mount points for each volume.

To invoke mount/unmount tasks use `vprotect mnt` sub-command.

```bash
vprotect mnt
# Incorrect syntax: Missing required option: [-T List tasks related to the mounted backup, -u Unmount previously mounted backup, -F List file systems, -l List mounted backups, -L List mounted files, -mi Mount iSCSI., -m Mount backup according to the MOUNT_SPECIFICATION, -Li List files for selected backup, that can be mounted using iSCSI mode.]

# usage: mnt -F <GUID> | -l | -L <GUID> | -Li <BACKUP_GUID> | -m <GUID> <NODE_CONFIG_GUID | NODE_CONFIG_NAME> <auto|manual> <MOUNT_SPECIFICATION> | -mi <BACKUP_GUID> <NODE_CONFIG_GUID | NODE_CONFIG_NAME> <ALLOWED_CLIENT,...,ALLOWED_CLIENT> <DISK_GUID,...,DISK_GUID> | -T <GUID> | -u <GUID>
# Mounted backup management
#  -F,--list-file-systems <GUID>                                                                                                         List file systems
#  -l,--list                                                                                                                             List mounted backups
#  -L,--list-files <GUID>                                                                                                                List mounted files
#  -Li,--list-iscsi-mountable-files <BACKUP_GUID>                                                                                        List files for selected backup, that can be mounted using iSCSI mode.
#  -m,--mount <GUID> <NODE_CONFIG_GUID | NODE_CONFIG_NAME> <auto|manual> <MOUNT_SPECIFICATION>                                           Mount backup according to the MOUNT_SPECIFICATION
#  -mi,--mount-iscsi <BACKUP_GUID> <NODE_CONFIG_GUID | NODE_CONFIG_NAME> <ALLOWED_CLIENT,...,ALLOWED_CLIENT> <DISK_GUID,...,DISK_GUID>   Mount iSCSI.
#  -T,--list-tasks <GUID>                                                                                                                List tasks related to the mounted backup
#  -u,--unmount <GUID>                                                                                                                   Unmount previously mounted backup
```

### Examples (Mounted backups)

*   To list all mounted backups:

    ```bash
    vprotect mnt -l
    ```
*   To list all mounted files used by mounted backup with GUID `1ac068d3-4848-4c98-b30b-54ce050b6a95` (**note** that this is mounted backup GUID not a backup GUID):

    ```bash
    vprotect mnt -L 1ac068d3-4848-4c98-b30b-54ce050b6a95
    ```
*   To show detected file systems in specific backup:

    ```bash
    vprotect mnt -F 1ac068d3-4848-4c98-b30b-54ce050b6a95
    ```
*   To mount all file systems in backup with GUID `2132182d-e9ab-4478-a1db-48222b0e515b` and node config with GUID `3a9d48dc-e48f-11eb-a1ce-005056a6b7e5` to /mnt/myVM/2017-01-01:

    ```bash
    vprotect mnt -m 2132182d-e9ab-4478-a1db-48222b0e515b 3a9d48dc-e48f-11eb-a1ce-005056a6b7e5 auto /mnt/myVM/2017-01-01
    ```
*   To mount manually file systems in backup with GUID `2132182d-e9ab-4478-a1db-48222b0e515b` with specifying mount points you need to provide semicolon-separated list where you provide name of the volume=mount point (white space before or after semicolon or equal sign is not allowed)

    ```bash
    vprotect mnt -m 2132182d-e9ab-4478-a1db-48222b0e515b manual "/dev/sda1=/mnt/myVM/sda1;/dev/vg_sda/lv_root=/mnt/myVM/lv_root"
    ```
*   To unmount mounted backup with GUID `1ac068d3-4848-4c98-b30b-54ce050b6a95`:

    ```bash
    vprotect mnt -u 1ac068d3-4848-4c98-b30b-54ce050b6a95
    ```

## Tasks

The Task Management module is used to show and cancel tasks being executed. You can also monitor the progress of the tasks.

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark>

* Tasks in the queue are run in order from the highest to the lowest priority.
* The queue is being periodically cleaned, so only the last tasks are being shown.
{% endhint %}

To manage tasks use `vprotect task` sub-command.

```bash
vprotect task
# Incorrect syntax: Missing required option: [-Q List queued tasks, -R List running tasks, -d Delete/cancel task, -F List finished (including failed) tasks, -g Show task details, -l List tasks (this node only), -L List tasks (all nodes and not assigned to any node)]

# usage: task -d <GUID> | -F | -g <GUID> | -l | -L | -Q | -R
# Task management
#  -d,--delete <GUID>    Delete/cancel task
#  -F,--list-finished    List finished (including failed) tasks
#  -g,--details <GUID>   Show task details
#  -l,--list             List tasks (this node only)
#  -L,--list-all         List tasks (all nodes and not assigned to any node)
#  -Q,--list-queued      List queued tasks
#  -R,--list-running     List running tasks
```

### Examples (Tasks)

*   To list tasks assigned to the current node:

    ```bash
    vprotect task -l
    ```
*   To list all tasks in the system:

    ```bash
    vprotect task -L
    ```
*   To show task details:

    ```bash
    vprotect task -g 091d623d-edea-490f-8b3b-da30c09a3f93
    ```
*   To cancel the task with ID `091d623d-edea-490f-8b3b-da30c09a3f93`:

    ```bash
    vprotect task -d 091d623d-edea-490f-8b3b-da30c09a3f93
    ```

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> Some tasks may need to be finished before they are cancelled, for example export VM from the hypervisor – after cancellation it may take some time for the task to process the cancel request and clean up the snapshots etc. If necessary, the backup will be marked as failed.
{% endhint %}

## Project

The Project module is used to view details and set a quota for available projects.

```bash
vprotect project
# Incorrect syntax: Missing required option: [-g Show Project details, -l List Projects, -sQ Set Project Quota]

# usage: project -g <GUID> | -l | -sQ <GUID> <QUOTA_GUID>
# Project management
#  -g,--details <GUID>                   Show Project details
#  -l,--list                             List Projects
#  -sQ,--set-quota <GUID> <QUOTA_GUID>   Set Project Quota
```

### Examples (Project)

*   To list all projects:

    ```bash
    vprotect project -l
    ```
*   To set quota with GUID `6f0bfb3c-24dd-4d12-8a72-997ded2ecc98` to project with GUID `ca707d31-f403-40d5-b160-6ac512457b87`

    ```bash
    vprotect project -sQ ca707d31-f403-40d5-b160-6ac512457b87 6f0bfb3c-24dd-4d12-8a72-997ded2ecc98
    ```

## User Management

The User module is used to manage users and their settings. You can add or remove users, change their password or timezone.

```bash
vprotect user
# Incorrect syntax: Missing required option: [-c Create user, -d Delete user, -g Show user details, -l List users, -m Update user's property, -sP Update user's password, -sA Update user's activation state]

# usage: user -c <LOGIN> <FIRST_NAME> <LAST_NAME> <TIMEZONE> <LANGUAGE> <ACTIVE> | -d <GUID> | -g <GUID> | -l | -m <GUID> <PROPERTY_NO.> <VALUE> | -sA <GUID> <ACTIVE> | -sP <GUID>>
# User management
#  -c,--create <LOGIN> <FIRST_NAME> <LAST_NAME> <TIMEZONE> <LANGUAGE> <ACTIVE>   Create user
#  -d,--delete <GUID>                                                            Delete user
#  -g,--details <GUID>                                                           Show user details
#  -l,--list                                                                     List users
#  -m,--modify <GUID> <PROPERTY_NO.> <VALUE>                                     Update user's property
#  -sA,--set-active <GUID> <ACTIVE>                                              Update user's activation state
#  -sP,--set-password <GUID>>
```

### Examples (User Management)

*   To create a new user

    ```bash
    vprotect user -c jdoe John Doe UTC EN true
    ```
*   To list all users

    ```bash
    vprotect user -l
    ```

    ```bash
                    GUID                  First Name  Last Name  Active
    ------------------------------------  ----------  ---------  ------
                                      1  The         Admin      true
    259c07ab-5097-4826-8a91-dd281840faf5  John        Doe        true
    ```
*   To set password for the user

    ```bash
    vprotect user -sP 705490c2-7734-4a56-a563-24471447bf2b
    ```

## Quota

Quota management module is used to manage backup/restore limits for virtual machines in projects.

To manage Quotas in the system use `vprotect quota` sub-command.

```bash
vprotect quota
# Incorrect syntax: Missing required option: [-aR Add Rule to Quota, -c Create Quota, -d Delete Quota, -g Show Quota details, -sN Change Quota name, -l List Quotas, -L List Projects for Quota, -eR Edit Rule in Quota, -sA Change Quota active state, -dR Delete Rule from Quota]

# usage: quota -aR <GUID> <RULE_NAME> <TYPE> <ACTIVE> <HARD_LIMIT> <HARD_LIMIT_TIME_FRAME> <SOFT_LIMIT> <SOFT_LIMIT_TIME_FRAME> | -c <NAME> | -d <GUID> | -dR <GUID> <RULE_NAME> <TYPE> | -eR <GUID> <RULE_NAME> <TYPE> <ACTIVE>
#        <HARD_LIMIT> <HARD_LIMIT_TIME_FRAME> <SOFT_LIMIT> <SOFT_LIMIT_TIME_FRAME> | -g <GUID> | -l | -L <GUID> | -sA <GUID> <ACTIVE> | -sN <GUID> <NAME>
# Quota management
#  -aR,--add-rule <GUID> <RULE_NAME> <TYPE> <ACTIVE> <HARD_LIMIT> <HARD_LIMIT_TIME_FRAME> <SOFT_LIMIT> <SOFT_LIMIT_TIME_FRAME>    Add Rule to Quota
#  -c,--create <NAME>                                                                                                             Create Quota
#  -d,--delete <GUID>                                                                                                             Delete Quota
#  -dR,--delete-rule <GUID> <RULE_NAME> <TYPE>                                                                                    Delete Rule from Quota
#  -eR,--edit-rule <GUID> <RULE_NAME> <TYPE> <ACTIVE> <HARD_LIMIT> <HARD_LIMIT_TIME_FRAME> <SOFT_LIMIT> <SOFT_LIMIT_TIME_FRAME>   Edit Rule in Quota
#  -g,--details <GUID>                                                                                                            Show Quota details
#  -l,--list                                                                                                                      List Quotas
#  -L,--list-projects <GUID>                                                                                                      List Projects for Quota
#  -lR,--list-all-rules                                                                                                           List all possible rule names
#  -sA,--set-active <GUID> <ACTIVE>                                                                                               Change Quota active state
#  -sN,--set-name <GUID> <NAME>                                                                                                   Change Quota name
```

### Examples (Quota)

*   To list all quotas:

    ```bash
    vprotect quota -l
    ```
*   To list all projects for Quota with GUID `1ac068d3-4848-4c98-b30b-54ce050b6a95`:

    ```bash
    vprotect quota -L 1ac068d3-4848-4c98-b30b-54ce050b6a95
    ```
*   To list all possible rule names:

    ```bash
    vprotect quota -lR
    ```
*   To add rule to Quota with GUID `1ac068d3-4848-4c98-b30b-54ce050b6a95`:

    ```bash
    vprotect quota -aR 1ac068d3-4848-4c98-b30b-54ce050b6a95 NUMBER_OF_BACKUPS TOTAL true 10 24 5 10
    ```

## RBAC

This module allows listing possible context types and privilege types used in RBAC management.

This module uses `vprotect rbac` sub-command.

```bash
vprotect rbac
# Incorrect syntax: Missing required option: [-lp List all possible privilege types, -lc List all possible context types]

# usage: rbac -lc | -lp
# User management
#  -lc,--list-context     List all possible context types
#  -lp,--list-privilege   List all possible privilege types
```

### Examples (RBAC)

*   To list all possible privilege types

    ```bash
    vprotect rbac -lp
    ```

## User Role Management

The User Role management module is used to manage Roles and their privileges.

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> only rules that are created by the user can be deleted.
{% endhint %}

To manage User Roles in the system use `vprotect role` sub-command.

```bash
vprotect role
# Incorrect syntax: Missing required option: [-rC Remove context from the role, -aC Add context to role, -c Create role, -d Delete role, -g Get role details, -lC List contexts of the role, -l Get role list, -m Modify role name, -rP Remove privilege from the role, -aP Add privilege to role]

# usage: role -aC <GUID> | -aP <GUID> <PRIVILEGE NAME> | -c <NAME> | -d <GUID> | -g <GUID> | -l | -lC <GUID> | -m <GUID> <NAME> | -rC <GUID> <CONTEXT INSTANCE GUID> | -rP <GUID> <PRIVILEGE NAME>
# +Access management
#  -aC,--add-context <GUID>                              Add context to role
#  -aP,--add-privilege <GUID> <PRIVILEGE_NAME>           Add privilege to role
#  -c,--create <NAME>                                    Create role
#  -d,--delete <GUID>                                    Delete role
#  -g,--details <GUID>                                   Get role details
#  -l,--list                                             Get role list
#  -lC,--list-contexts <GUID>                            List contexts of the role
#  -m,--modify <GUID> <NAME>                             Modify role name
#  -rC,--remove-context <GUID> <CONTEXT_INSTANCE_GUID>   Remove context from the role
#  -rP,--remove-privilege <GUID> <PRIVILEGE_NAME>        Remove privilege from the role
```

### Examples (User Role Management)

* To create a new Role

```bash
  vprotect role -c Tester
```

* To add VE\_INSTANCE\_READ privilege to a Role with GUID `1ac068d3-4848-4c98-b30b-54ce050b6a95`

```bash
  vprotect role -aP 1ac068d3-4848-4c98-b30b-54ce050b6a95 VE_INSTANCE_READ
```

## User Group Management

+User Group management module is used to bind Users with a set of Roles.

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> Only groups that are created by the user can be deleted.
{% endhint %}

To manage User Roles in the system use `vprotect group` sub-command.

```bash
# vprotect group
# Incorrect syntax: Missing required option: [-rR Remove role from the group, -aR Add role to the group, -c Create group, -rU Remove user from the group, -d Delete group, -aU Add user to the group, -g Get group details, -l Get group list, -m Modify group name]

# usage: group -aR <GUID> <ROLE GUID> | -aU <GUID> <USER_GUID> | -c <NAME> | -d <GUID> | -g <GUID> | -l | -m <GUID> <NAME> | -rR <GUID> <ROLE_GUID> | -rU <GUID> <USER_GUID>
# AppUser Group management
#  -aR,--add-role <GUID> <ROLE GUID>      Add role to the group
#  -aU,--add-user <GUID> <USER_GUID>      Add user to the group
#  -c,--create <NAME>                     Create group
#  -d,--delete <GUID>                     Delete group
#  -g,--details <GUID>                    Get group details
#  -l,--list                              Get group list
#  -m,--modify <GUID> <NAME>              Modify group name
#  -rR,--remove-role <GUID> <ROLE_GUID>   Remove role from the group
#  -rU,--remove-user <GUID> <USER_GUID>   Remove user from the group
```

### Examples (User Group Management)

*   To add Role with GUID `1ac068d3-4848-4c98-b30b-54ce050b6a95` to Group with GUID `54c57989-9d99-480f-a6da-b4f34b7bd812`

    ```bash
    vprotect group -aR 54c57989-9d99-480f-a6da-b4f34b7bd812 1ac068d3-4848-4c98-b30b-54ce050b6a95
    ```
*   To remove User with GUID `91e6bf9c-59c6-4653-9854-e9c920198343` from Group with GUID `54c57989-9d99-480f-a6da-b4f34b7bd812`

    ```bash
      vprotect group -rU 54c57989-9d99-480f-a6da-b4f34b7bd812 91e6bf9c-59c6-4653-9854-e9c920198343
    ```

## Application backup/restore

This module is used to manage tge backup and restore process. It is also used to list backups of a particular application.

To invoke backup and restore tasks use `vprotect brapp` sub-command.

```bash
vprotect brapp
# Required option: [-b Backup (full), -B Backup (full) with task priority (0-100, 50 = default), -r Restore the backup, -T List tasks related to the backup, -gL Show file details, -I Restore and import backup. Enter D as path for DEFAULT source path from application, -gb Show backup details, -l List backups, -L List backup files]

# usage: brapp -b <GUID> <BP_GUID | BP_NAME> | -B <GUID> <BP_GUID | BP_NAME> <PRIORITY> | -gb <BACKUP_GUID> | -gL <BACKUP_FILE_GUID> | -I <BACKUP_GUID>
#        <DST_APP_GUID> <PATH> | -l | -L <GUID> | -r <GUID> <NODE_GUID | NODE_NAME> <DIRECTORY> | -T <GUID>
# Application backup & restore
#  -b,--backup <GUID> <BP_GUID | BP_NAME>                            Backup (full)
#  -B,--backup-with-priority <GUID> <BP_GUID | BP_NAME> <PRIORITY>   Backup (full) with task priority (0-100, 50 = default)
#  -gb,--show-backup-details <BACKUP_GUID>                           Show backup details
#  -gL,--show-files-details <BACKUP_FILE_GUID>                       Show file details
#  -I,--restore-and-import <BACKUP_GUID> <DST_APP_GUID> <PATH>       Restore and import backup. Enter D as path for DEFAULT source path from application
#  -l,--list                                                         List backups
#  -L,--list-files <GUID>                                            List backup files
#  -r,--restore <GUID> <NODE_GUID | NODE_NAME> <DIRECTORY>           Restore the backup
#  -T,--list-tasks <GUID>                                            List tasks related to the backup
```

### Examples (Application backup/restore)

*   To list all backups and their status:

    ```bash
    vprotect brapp -l
    ```
*   To show backups of a particular VM:

    ```bash
    vprotect app -L 0f36f40c-6427-4035-9f2b-1ead6aca3597
    ```
*   To show files that a specific backup consists of:

    ```bash
    vprotect brapp -L 4f1c7907-72e9-4797-8470-3f1fbb081751
    ```
*   To create a full backup of a app and store it in backup destination called `MyTSM`

    ```bash
    vprotect brapp -b 0f36f40c-6427-4035-9f2b-1ead6aca3597 MyTSM
    ```
*   To restore a full backup with given GUID on the current node (`this`) to the `/vprotect_data`

    ```bash
    vprotect brapp -r 2132182d-e9ab-4478-a1db-48222b0e515b this /vprotect_data
    ```
* To restore application backup (first GUID) to the other application (assuming it has REMOTE\_SSH in Command Execution Configuration - second GUID)
* ```bash
  vprotect brapp -H 2132182d-e9ab-4478-a1db-48222b0e515b c93140b8-a898-4aff-8eef-645587ca8289 "Local storage"
  ```

## Applications

The Application management module is used to provide information about apps that have been defined report the status of the last backup of your apps (and all backups for a particular app).

To manage Applications in the system used `vprotect app` sub-command.

```bash
vprotect app
# Required option: [-A Assign application backup policy, -dE Delete environment variable, -c Create a new application, -d Delete an application, -aE Add environment variable to application, -g Show application details, -xC Set application CMD exec configuration, -l List applications, -L List backups of the application, -m Modify application, -sC Set SSH access credentials, -sH Set SSH access host/port, -sK Set SSH key path, -mE Modify environment variable. Set variable hidden in UI(1) or visible(0), -lE List environment variables for application, -sN Set application node]

# usage: app -A <GUID> <APP_POLICY_GUID> | -aE <APP_GUID> <NAME> <VALUE> | -c <NAME> <CONFIG_GUID> | -d <GUID> | -dE <GUID> | -g <GUID> | -l | -L <GUID> | -lE
#        <APP_GUID> | -m <GUID> <NAME> | -mE <GUID> <APP_GUID> <NAME> <VALUE> <0|1> | -sC <GUID> <SSH_USER> <SSH_PASS> | -sH <GUID> <SSH_HOST> <SSH_PORT> | -sK
#        <GUID> <SSH_KEYPATH> | -sN <GUID> <NODE_GUID> | -xC <GUID> <APP_CMD_EXEC_CONFIG_GUID>
# Application backup management
#  -A,--assign-app-policy <GUID> <APP_POLICY_GUID>                    Assign application backup policy
#  -aE,--add-env-variable <APP_GUID> <NAME> <VALUE>                   Add environment variable to application
#  -c,--create <NAME> <CONFIG_GUID>                                   Create a new application
#  -d,--delete <GUID>                                                 Delete an application
#  -dE,--delete-env-variable <GUID>                                   Delete environment variable
#  -g,--details <GUID>                                                Show application details
#  -l,--list                                                          List applications
#  -L,--list-backups <GUID>                                           List backups of the application
#  -lE,--list-env-variables <APP_GUID>                                List environment variables for application
#  -m,--modify <GUID> <NAME>                                          Modify application
#  -mE,--modify-env-variable <GUID> <APP_GUID> <NAME> <VALUE> <0|1>   Modify environment variable. Set variable hidden in UI(1) or visible(0)
#  -sC,--set-ssh-credentials <GUID> <SSH_USER> <SSH_PASS>             Set SSH access credentials
#  -sH,--set-ssh-host <GUID> <SSH_HOST> <SSH_PORT>                    Set SSH access host/port
#  -sK,--set-ssh-key-path <GUID> <SSH_KEYPATH>                        Set SSH key path
#  -sN,--set-node <GUID> <NODE_GUID>                                  Set application node
#  -xC,--set-app-cmd-exec-config <GUID> <APP_CMD_EXEC_CONFIG_GUID>    Set application CMD exec configuration
```

### Examples (Applications)

*   To list all Applications

    ```bash
    vprotect app -l
    ```
*   To show details of the given Application (by GUID)

    ```bash
    vprotect app -g 0f36f40c-6427-4035-9f2b-1ead6aca3597
    ```
*   To add Application (first GUID) to the given policy (second GUID):

    ```bash
    vprotect app -A 0f36f40c-6427-4035-9f2b-1ead6aca3597 3afcd507-a4f5-484d-8d34-53c73d7a5809
    ```
*   To show backup history of a VM with given GUID:

    ```bash
    vprotect app -L 0f36f40c-6427-4035-9f2b-1ead6aca3597
    ```

## Application backup policies

Application backup policies management module is used to define backup policies for Applications. You can assign different backup priorities for a policy when the scheduler invokes a backup task. You need first to define the application backup policy and then add Applications to it. The Application can belong only to a single backup policy.

To manage Application policies in the system used `vprotect apppolicy` sub-command.

{% hint style="info" %}
<mark style="color:blue;">**Note.**</mark> It is important to assign a backup destination for a policy (required for a node to know where to store backups).
{% endhint %}

Application backup policies are supposed to have multiple rules (but currently vProtect supports exactly 1 rule). Rule specifies schedules and backup destinations for the policies.

```bash
vprotect apppolicy
# Required option: [-p Set policy's backup task priority (0-100, 50 = default), -rR Remove rules from policy, -A Assign applications to policy, -aR Add new rule to selected policy, -r List rules for application backup policy, -c Create application backup policy, -d Delete a policy, -U Unassign applications from policy, -g Show details, -l List policies, -m Modify application backup policy]

# usage: apppolicy -A <GUID> <APP_GUID,...,APP_GUID> | -aR <NAME> <POLICY_GUID> <SCHEDULE_GUID> <BACKUP_DESTINATION_GUID> | -c <NAME> <PRIORITY> | -d <GUID> |
#        -g <GUID> | -l | -m <GUID> <NAME> <PRIORITY> | -p <GUID> <PRIORITY> | -r <GUID> | -rR <POLICY_GUID> <RULE_GUID,...,RULE_GUID> | -U <GUID>
#        <APP_GUID,...,APP_GUID>
# Application backup policy management
#  -A,--assign applications <GUID> <APP_GUID,...,APP_GUID>                         Assign applications to policy
#  -aR,--add-rule <NAME> <POLICY_GUID> <SCHEDULE_GUID> <BACKUP_DESTINATION_GUID>   Add new rule to selected policy
#  -c,--create <NAME> <PRIORITY>                                                   Create application backup policy
#  -d,--delete <GUID>                                                              Delete a policy
#  -g,--details <GUID>                                                             Show details
#  -l,--list                                                                       List policies
#  -m,--modify <GUID> <NAME> <PRIORITY>                                            Modify application backup policy
#  -p,--set-priority <GUID> <PRIORITY>                                             Set policy's backup task priority (0-100, 50 = default)
#  -r,--list-rules <GUID>                                                          List rules for application backup policy
#  -rR,--remove-rules <POLICY_GUID> <RULE_GUID,...,RULE_GUID>                      Remove rules from policy
#  -U,--unassign applications <GUID> <APP_GUID,...,APP_GUID>                       Unassign applications from policy
```

### Examples (Application backup policies)

*   To list all application backup policies

    ```bash
    vprotect apppolicy -l
    ```
*   To show details of the given application (by GUID)

    ```bash
    vprotect apppolicy -g 3afcd507-a4f5-484d-8d34-53c73d7a5809
    ```
*   To create a new policy

    ```bash
    vprotect apppolicy -c "My Policy" 50
    ```
*   To set backup destination for a policy:

    ```bash
    Syntax: -aR <NAME> <POLICY_GUID> <SCHEDULE_GUID> <BACKUP_DESTINATION_GUID>
    vprotect apppolicy -aR MyPolicyRule d804439e-aeda-4fea-8f79-710dc355d2d1 1076134b-4e29-45ea-8c79-1e8ca216a3b8  9038d316-5d02-4972-913b-4201f4947178
    ```

## Application command execution management

Application command execution management module is used to define command execution for application. You can assign application to command definition or show details of command config. As you can see in the module syntax, you can do much more and we will show such operations in examples.

```bash
vprotect appconf
# Required option: [-sS Set source path. Please remember that wildcard paths should be specified inside double quotes., -A Assign applications to config, -c Create application command execution config, timeout [min.], -d Delete application command execution config, -e Set export data to false(0) or true(1), -g Show details, -l List application command execution configs, -m Modify application command execution config", -sC Set CMD as semi-colon-separated string, i.e. "cmd;-a;-b", -r Remove files after export to false(0) or true(1), -sE Set handling for standard error. Values: DONT_IGNORE, IGNORE_WITH_WARNING, IGNORE_WITHOUT_WARNING, -t Set timeout in minutes, -U Unassign applications from config, -sI Set ignored command exit codes e.g. '15, 101-150' or '*']

# usage: appconf -A <GUID> <APP_GUID,...,APP_GUID> | -c <NAME> <NODE | REMOTE_SSH> <FILE | STREAM> <TIMEOUT> | -d <GUID> | -e <GUID> <0|1>
#        | -g <GUID> | -l | -m <GUID> <NAME> <NODE | REMOTE_SSH> <FILE | STREAM> | -r <GUID> <0|1> | -sC <GUID> <CMD_STRING> | -sE <GUID>
#        <HANDLING> | -sI <GUID> <IGNORED_EXIT_CODES> | -sS <GUID> <SOURCE_PATH> | -t <GUID> <TIMEOUT> | -U <GUID> <APP_GUID,...,APP_GUID>
# App command execution management
#  -A,--assign-applications <GUID> <APP_GUID,...,APP_GUID>            Assign applications to config
#  -c,--create <NAME> <NODE | REMOTE_SSH> <FILE | STREAM> <TIMEOUT>   Create application command execution config, timeout [min.]
#  -d,--delete <GUID>                                                 Delete application command execution config
#  -e,--set-export-data <GUID> <0|1>                                  Set export data to false(0) or true(1)
#  -g,--details <GUID>                                                Show details
#  -l,--list                                                          List application command execution configs
#  -m,--modify <GUID> <NAME> <NODE | REMOTE_SSH> <FILE | STREAM>      Modify application command execution config"
#  -r,--remove-after-export <GUID> <0|1>                              Remove files after export to false(0) or true(1)
#  -sC,--set-cmd-arg <GUID> <CMD_STRING>                              Set CMD as semi-colon-separated string, i.e. "cmd;-a;-b"
#  -sE,--set-std-error <GUID> <HANDLING>                              Set handling for standard error. Values: DONT_IGNORE,
#                                                                     IGNORE_WITH_WARNING, IGNORE_WITHOUT_WARNING
#  -sI,--set-ignored-codes <GUID> <IGNORED_EXIT_CODES>                Set ignored command exit codes e.g. '15, 101-150' or '*'
#  -sS,--set-source-path <GUID> <SOURCE_PATH>                         Set source path. Please remember that wildcard paths should be
#                                                                     specified inside double quotes.
#  -t,--timeout <GUID> <TIMEOUT>                                      Set timeout in minutes
#  -U,--unassign-applications <GUID> <APP_GUID,...,APP_GUID>          Unassign applications from config
```

### Examples (Application command execution management)

* To list all command configs:

```bash
vprotect appconf -l

#                 GUID                             Name             CmdExecMethod  Applications  Export data  Remove files after export  Source type
# ------------------------------------  --------------------------  -------------  ------------  -----------  -------------------------  -----------
# 758112e8-2db6-46b1-8a65-ee7064f4933f  DB2                         Remote SSH     -             true         true                       File
# f807b3b1-7909-471f-8224-b8948dfca91f  file-backup                 Remote SSH     -             true         false                      File
# 8b5e2b3f-3837-4f9d-a52a-fa7e9d0378fe  Kubernetes/OpenShift etcd   Remote SSH     -             true         true                       File
# 9a6b1277-4388-42c3-8f81-ea4af6b0b27c  mysql                       Remote SSH     -             true         true                       File
# 785ac097-cd1d-43e3-92c3-ac42d710adb3  MySQL/MariaDB               Remote SSH     -             true         true                       File
# 49fa4b52-0fda-44db-a692-7ee8ed071b86  MySQL/MariaDB_2             Remote SSH     -             true         true                       File
```

* To see command config details:

```bash
vprotect appconf -g 9a6b1277-4388-42c3-8f81-ea4af6b0b27c
# Property                   Value
# -------------------------  ------------------------------------------------------------

# GUID                       9a6b1277-4388-42c3-8f81-ea4af6b0b27c
# Name                       mysql
# CmdArg                     [$VP_MYSQL_SCRIPTPATH/vp_backup_mysql.sh, >>, $VP_MYSQL_LOGFILE]
# Applications               []
# Cmd execution method       REMOTE_SSH
# Export data                true
# Remove files after export  true
# Source type                FILE
# Source path                $VP_MYSQL_STOREPATH/*
# Timeout in minutes         60
# Ignored exit codes         -
# Standard error handling    DONT_IGNORE
```

## Restore Jobs

You can use this small module to list restore job operations and see the details of every task.

```bash
vprotect restorejob
# Incorrect syntax: Missing required option: [-g Show restore job details, -l List restore jobs]

# usage: restorejob -g <RESTOREJOB_GUID> | -l
# Restore jobs
#  -g,--show-restore-job-details <RESTOREJOB_GUID>   Show restore job details
#  -l,--list                                         List restore jobs
```

### Examples (Restore Jobs)

* To list restore jobs:

```bash
vprotect restorejob -l

#                 GUID                     Restore Type     Status                                                                                           Status info                                                                                           VM/APP
# ------------------------------------  ------------------  -------  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  ------
# e9aff98f-e431-467f-b9f9-46b2f86068eb  Restore and mount   Success  Backups of VM: [PM]Windows_2016 (size: 50 GiB) mounted in: 1m 14s.                                                                                                                            -
# 0dcdfed3-f793-4b9f-8faf-a608396de8e8  Restore             Failed   ExternalAPIException: Failed to create directory: /vprotect_data/import/a2778f74-dc6c-4a1d-88ea-1f85361f4fbd/VM_01_Apine/2020-06-08__11.50.                                                   -
# fd99c9ec-ac25-448c-a973-d654936076b2  Restore             Failed   Backup destination is not assigned to the node                                                                                                                                                -
# f23c2c8c-2bec-4e8e-9ba9-2c6251434907  Restore and mount   Success  Backups of VM: alpine (size: 2.3 GiB) mounted in: 1m 31s
# a24f15c0-617f-4808-869a-ed346e30a713  Restore and import  Success  Backups of VM: Alpine-Linux (size: 2 GiB) imported in: 3m 5s.
```

* To see restore job details:

```bash
vprotect restorejob -g e9aff98f-e431-467f-b9f9-46b2f86068eb
# Property                         Value
# -------------------------------  ------------------------------------------------------------

# GUID                             e9aff98f-e431-467f-b9f9-46b2f86068eb
# Restore Type                     RESTORE_AND_MOUNT
# Status                           SUCCESS
# Status info                      Backups of VM: [PM]Windows_2016 (size: 50 GiB) mounted in: 1m 14s.
# VM/APP                           -
# Tasks                            0
# Backup                           1906e226-2ba6-439a-b723-31efb6e5196a
# Destination VM/APP               [PM]Windows_2016 (f2354325-562e-465b-abc4-c4db51036b80)
# Restore Storage ID               -
# Restore Cluster ID               -
# Restored VM/APP Name             -
# Restore Project Name             -
# Restore Path                     -
# Tenant ID                        -
# Base Image                       -
# Data Center Name                 -
# Restored Disk Allocation Format  -
# Mounted Backup Mode              AUTO
# Backup Type                      FULL
# Node                             vPro-Local (b46043f2-df06-482c-b4ba-37fc8093022c)
```

## Recovery plans policies

The Recovery plans policies module is used to define recovery plans policies and rules for VMs. You can assign different restore priorities for a policy when the scheduler invokes the restore task. You need first to create a new policy and then add new rules to it.

```bash
vprotect recplan
# Required option: [-sRrci Set restore cluster id in rule, -sRa Set rule status, -sRhvmt Set hypervisor manager type in rule, -sRuag Set rule use auto generated name, -sRrp Set restore path in rule, -sRdc Set data center in rule, -sRn Set node in rule, -sRrn Set target VM name in rule, -sRtp Set target project in rule, -aR Add new rule to selected policy, -sRdaf Set disk allocation format in rule, -sRrsi Set restore storage id in rule, -sRv Add virtual machines to rule, -rR Remove rules from policy, -c Create a new policy, -d Delete a policy, -sRbs Set backup selection in rule, -g Show details, -sRovw Set overwrite status in rule, -l List policies, -m Modify policy, -p Set policy's backup task priority (0-100, 50 = default), -r List rules for policy, -srBi Set base image in rule, -sRhv Set hypervisor in rule, -sRhvm Set hypervisor manager in rule, -sRhvt Set hypervisor type in rule]

# usage: recplan -aR <NAME> <POLICY_GUID>> | -c <NAME> | -d <GUID> | -g <GUID> | -l | -m <GUID> <NAME> | -p <GUID> <PRIORITY> | -r <GUID> |
#        -rR <POLICY_GUID> <RULE_GUID,...,RULE_GUID> | -sRa <RULE_GUID> <TRUE|FALSE>> | -srBi <RULE_GUID> <BASE_IMAGE_UUID>> | -sRbs
#        <RULE_GUID> <LAST_SUCCESSFUL | ANY>> | -sRdaf <RULE_GUID> <PREALLOCATED | SPARSE>> | -sRdc <RULE_GUID> <DATA_CENTER_NAME>> | -sRhv
#        <RULE_GUID> <HYPERVISOR_GUID>> | -sRhvm <RULE_GUID> <HYPERVISORMANAGER_GUID>> | -sRhvmt <RULE_GUID> <HYPERVISORMANAGERTYPE>> |
#        -sRhvt <RULE_GUID> <HYPERVISORTYPE>> | -sRn <RULE_GUID> <NODE_GUID>> | -sRovw <RULE_GUID> <TRUE|FALSE>> | -sRrci <RULE_GUID>
#        <RESTORE_CLUSTER_ID>> | -sRrn <RULE_GUID> <VM_NAME>> | -sRrp <RULE_GUID> <PATH>> | -sRrsi <RULE_GUID> <RESTORE_STORAGE_ID>> |
#        -sRtp <RULE_GUID> <PROJECT_NAME>> | -sRuag <RULE_GUID> <TRUE|FALSE>> | -sRv <RULE_GUID> <VM_GUIDS>>
# Recovery plan policies
#  -aR,--add-rule <NAME> <POLICY_GUID>>                                            Add new rule to selected policy
#  -c,--create <NAME>                                                              Create a new policy
#  -d,--delete <GUID>                                                              Delete a policy
#  -g,--details <GUID>                                                             Show details
#  -l,--list                                                                       List policies
#  -m,--modify <GUID> <NAME>                                                       Modify policy
#  -p,--set-priority <GUID> <PRIORITY>                                             Set policy's backup task priority (0-100, 50 = default)
#  -r,--list-rules <GUID>                                                          List rules for policy
#  -rR,--remove-rules <POLICY_GUID> <RULE_GUID,...,RULE_GUID>                      Remove rules from policy
#  -sRa,--set-rule-active <RULE_GUID> <TRUE|FALSE>>                                Set rule status
#  -srBi,--set-rule-base-image <RULE_GUID> <BASE_IMAGE_UUID>>                      Set base image in rule
#  -sRbs,--set-rule-backup-selection <RULE_GUID> <LAST_SUCCESSFUL | ANY>>          Set backup selection in rule
#  -sRdaf,--set-rule-disk-allocation-format <RULE_GUID> <PREALLOCATED | SPARSE>>   Set disk allocation format in rule
#  -sRdc,--set-rule-data-center <RULE_GUID> <DATA_CENTER_NAME>>                    Set data center in rule
#  -sRhv,--set-rule-hv <RULE_GUID> <HYPERVISOR_GUID>>                              Set hypervisor in rule
#  -sRhvm,--set-rule-hvm <RULE_GUID> <HYPERVISORMANAGER_GUID>>                     Set hypervisor manager in rule
#  -sRhvmt,--set-rule-hvm-type <RULE_GUID> <HYPERVISORMANAGERTYPE>>                Set hypervisor manager type in rule
#  -sRhvt,--set-rule-hv-type <RULE_GUID> <HYPERVISORTYPE>>                         Set hypervisor type in rule
#  -sRn,--set-rule-node <RULE_GUID> <NODE_GUID>>                                   Set node in rule
#  -sRovw,--set-rule-overwrite <RULE_GUID> <TRUE|FALSE>>                           Set overwrite status in rule
#  -sRrci,--set-rule-restore-cluster-id <RULE_GUID> <RESTORE_CLUSTER_ID>>          Set restore cluster id in rule
#  -sRrn,--set-rule-restored-name <RULE_GUID> <VM_NAME>>                           Set target VM name in rule
#  -sRrp,--set-rule-restore-path <RULE_GUID> <PATH>>                               Set restore path in rule
#  -sRrsi,--set-rule-restore-storage-id <RULE_GUID> <RESTORE_STORAGE_ID>>          Set restore storage id in rule
#  -sRtp,--set-rule-target-project <RULE_GUID> <PROJECT_NAME>>                     Set target project in rule
#  -sRuag,--set-rule-use-auto-generated-name <RULE_GUID> <TRUE|FALSE>>             Set rule use auto generated name
#  -sRv,--set-rule-vms <RULE_GUID> <VM_GUIDS>>                                     Add virtual machines to rule
```

### Examples (Recovery plans policies)

* To create new policy:

```bash
vprotect recplan -c "New Recovery Policy"

#                 GUID                         Name          Priority  Rules
# ------------------------------------  -------------------  --------  -----
# d76bb990-817d-47ca-ba04-1dbdeffacf2a  New Recovery Policy  50        0
```

* To add new rule to selected policy:

```bash
vprotect recplan -aR Rule1 d76bb990-817d-47ca-ba04-1dbdeffacf2a
# Property      Value
# ------------  ------------------------------------

# GUID          d76bb990-817d-47ca-ba04-1dbdeffacf2a
# Name          New Recovery Policy
# Priority      50
# No. of rules  1
```

* To list policies:

```bash
vprotect recplan -l

#                 GUID                         Name          Priority  Rules
# ------------------------------------  -------------------  --------  -----
# d76bb990-817d-47ca-ba04-1dbdeffacf2a  New Recovery Policy  50        1
```

* To list rules assigned to policy:

```bash
vprotect recplan -r d76bb990-817d-47ca-ba04-1dbdeffacf2a

#                 GUID                  Name   VMs  Hypervisor Type  Hypervisor Manager Type  Hypervisor  Hypervisor Manager  Node  Backup Selection  Active  Restore Storage Id  Restore Cluster Id  Target VM Name  Target Project  Restore Path  Overwrite  Base Image  Data Center  Disk Allocation Format  Use auto generated name
# ------------------------------------  -----  ---  ---------------  -----------------------  ----------  ------------------  ----  ----------------  ------  ------------------  ------------------  --------------  --------------  ------------  ---------  ----------  -----------  ----------------------  -----------------------
# 6f0cc9ae-5842-4339-aee1-c8d21904317b  Rule1  []   -                -                        -           -                   -     Last successful   true    null  null  null  null  null  true       -           -            -                       false
```

* To select the virtual machine you want to restore using a rule :

```bash
vprotect vm -l      # To list virtual machines and their GUID's

vprotect recplan -sRv 6f0cc9ae-5842-4339-aee1-c8d21904317b f2354325-562e-465b-abc4-c4db51036b80

                <!-- GUID                         Name          Priority  Rules
------------------------------------  -------------------  --------  -----
d76bb990-817d-47ca-ba04-1dbdeffacf2a  New Recovery Policy  50        1 -->
```
