

# Committing files to WORM state
<a name="worm-state"></a>

This section discusses how you can transition your files to a write once, read many (WORM) state. It also discusses volume-append mode, which is a way to write data incrementally to WORM-protected files. 

## Autocommit
<a name="worm-state-autocommit"></a>

You can use autocommit to transition files to WORM if they haven't been modified for a period of time that you specify. You can turn on autocommit with the Amazon FSx console, the AWS CLI, the Amazon FSx API, and the ONTAP CLI and REST API. 

You can specify an autocommit period between five minutes and 10 years. The following table lists the specific ranges that are supported. 


****  

| Unit | Value | 
| --- | --- | 
|  Minutes  |  5 - 65,535  | 
|  Hours  |  1 - 65,535  | 
|  Days  |  1 - 3,650  | 
|  Months  |  1 - 120  | 
|  Years  |  1 - 10  | 

To turn on autocommit with the Amazon FSx API, use `AutocommitPeriod` in the [https://docs.aws.amazon.com/fsx/latest/APIReference/API_CreateSnaplockConfiguration.html](https://docs.aws.amazon.com/fsx/latest/APIReference/API_CreateSnaplockConfiguration.html). In the Amazon FSx console, for **Autocommit**, choose **Enabled**. Then, for **Autocommit period**, enter a value and choose a corresponding **Autocommit unit**. 

You can specify a value between 5 minutes and 10 years.

## Volume-append mode
<a name="worm-state-append"></a>

You can't modify existing data in a WORM-protected file. However, SnapLock allows you to maintain protection for existing data using WORM-appendable files. For example, you can generate log files or preserve audio or video streaming data while writing data to them incrementally. You can turn volume-append mode on or off with the Amazon FSx console, the AWS CLI, the Amazon FSx API, and the ONTAP CLI and REST API. 

**Requirements for updating volume-append mode**
+ The SnapLock volume must be unmounted.
+ The SnapLock volume must be empty of snapshot copies and user data. 

 

To turn on volume-append mode with the Amazon FSx API, use `VolumeAppendModeEnabled` in the [https://docs.aws.amazon.com/fsx/latest/APIReference/API_CreateSnaplockConfiguration.html](https://docs.aws.amazon.com/fsx/latest/APIReference/API_CreateSnaplockConfiguration.html). In the Amazon FSx console, for **Volume append mode**, choose **Enabled**. 

## Event-based retention (EBR)
<a name="worm-state-ebr"></a>

You can use event-based retention (EBR) to create custom policies with associated retention periods. For example, you can transition all files in a specified path to WORM and set the retention period for one year with the `snaplock event-retention policy create` and `snaplock event-retention apply` commands. When you use EBR, you must specify a volume, directory, or file. The retention period that you select when you create the EBR policy is applied to all files in the specified path. 

EBR is supported by the ONTAP CLI and REST API. 

**Note**  
ONTAP doesn't support EBR with FlexGroup volumes.

The following procedures explain how to create, apply, modify, and delete an EBR policy. You must be a SnapLock administrator (have the `vsadmin-snaplock` role) to complete these tasks in the ONTAP CLI. For more information, see [SnapLock administrator](how-snaplock-works.md#snaplock-admin). 

### Creating an EBR policy in the ONTAP CLI
<a name="create-ebr-ontap-cli"></a>

**To create an EBR policy in the ONTAP CLI**
+ Run the following command. Replace *p1* and *"10 years"* with your own information. 

  ```
  vs1::> snaplock event-retention policy create -name p1 -retention-period "10 years"
  ```

### Applying an EBR policy in the ONTAP CLI
<a name="apply-ebr-ontap-cli"></a>

**To apply an EBR policy in the ONTAP CLI**
+ Run the following command. Replace *p1* and *slc* with your own information. You can add a path after the forward slash (/) if you want to specify a particular path for the EBR policy. Otherwise, this command applies the EBR policy to all files on the volume. 

  ```
  vs1::> snaplock event-retention apply -policy-name p1 -volume slc -path /
  ```

### Modifying an EBR policy in the ONTAP CLI
<a name="modify-ebr-ontap-cli"></a>

**To modify an EBR policy in the ONTAP CLI**
+ Run the following command. Replace *p1* and *"5 years"* with your own information. 

  ```
  vs1::> snaplock event-retention policy modify -name p1 -retention-period "5 years"
  ```

### Deleting an EBR policy in the ONTAP CLI
<a name="delete-ebr-ontap-cli"></a>

**To delete an EBR policy in the ONTAP CLI**
+ Run the following command. Replace *p1* with your own information. 

  ```
  vs1::> snaplock event-retention policy delete -name p1
  ```

Related commands in the *NetApp Documentation Center*:
+ [snaplock event-retention abort](https://docs.netapp.com/us-en/ontap-cli-9121/snaplock-event-retention-abort.html)
+ [snaplock event-retention show-vservers](https://docs.netapp.com/us-en/ontap-cli-9121/snaplock-event-retention-show-vservers.html)
+ [snaplock event-retention show](https://docs.netapp.com/us-en/ontap-cli-9121/snaplock-event-retention-show.html)
+ [snaplock event-retention policy show](https://docs.netapp.com/us-en/ontap-cli-9121/snaplock-event-retention-policy-show.html)

## Legal Hold
<a name="worm-state-legal-hold"></a>

You can retain WORM files for an indefinite period of time using Legal Hold. Legal Hold is generally used for litigation purposes. A WORM file that's subject to a Legal Hold can't be deleted until the Legal Hold is lifted. 

Legal Hold is supported by the ONTAP CLI and REST API. 

**Note**  
ONTAP doesn't support Legal Hold with FlexGroup volumes.

The following procedures explain how to start and end a Legal Hold. You must be a SnapLock administrator (have the `vsadmin-snaplock` role) to complete these tasks in the ONTAP CLI. For more information, see [SnapLock administrator](how-snaplock-works.md#snaplock-admin). 

### Starting a Legal Hold on a file in a SnapLock Compliance volume with the ONTAP CLI
<a name="start-legal-hold-ontap-cli"></a>

**To start a Legal Hold on a file in a SnapLock Compliance volume with the ONTAP CLI**
+ Run the following command. Replace *litigation1*, *slc\$1vol1*, and *file1* with your own information. 

  ```
  vs1::> snaplock legal-hold begin -litigation-name litigation1 -volume slc_vol1 -path /file1
  ```

### Starting a Legal Hold on all files in a SnapLock Compliance volume with the ONTAP CLI
<a name="start-legal-hold-all-files-ontap-cli"></a>

**To start a Legal Hold on all files in a SnapLock Compliance volume with the ONTAP CLI**
+ Run the following command. Replace *litigation1* and *slc\$1vol1* with your own information. 

  ```
  vs1::> snaplock legal-hold begin -litigation-name litigation1 -volume slc_vol1 -path /
  ```

### Ending a Legal Hold on a file in a SnapLock Compliance volume with the ONTAP CLI
<a name="end-legal-hold-ontap-cli"></a>

**To end a Legal Hold on a file in a SnapLock Compliance volume with the ONTAP CLI**
+ Run the following command. Replace *litigation1*, *slc\$1vol1*, and *file1* with your own information. 

  ```
  vs1::> snaplock legal-hold end -litigation-name litigation1 -volume slc_vol1 -path /file1
  ```
**Note**  
We recommend that you monitor the `-operation-status` with the `snaplock legal-hold show` command when issuing a Legal Hold to make sure that it doesn't fail. 

### Ending a Legal Hold on all files in a SnapLock Compliance volume with the ONTAP CLI
<a name="end-legal-hold-all-files-ontap-cli"></a>

**To end a Legal Hold on all files in a SnapLock Compliance volume with the ONTAP CLI**
+ Run the following command. Replace *litigation1* and *slc\$1vol1* with your own information. 

  ```
  vs1::> snaplock legal-hold end -litigation-name litigation1 -volume slc_vol1 -path /
  ```
**Note**  
We recommend that you monitor the `-operation-status` with the `snaplock legal-hold show` command when issuing a Legal Hold to make sure that it doesn't fail. 

 Related commands in the *NetApp Documentation Center*:
+ [snaplock legal-hold abort](https://docs.netapp.com/us-en/ontap-cli-9121/snaplock-legal-hold-abort.html)
+ [snaplock legal-hold dump-files](https://docs.netapp.com/us-en/ontap-cli-9121/snaplock-legal-hold-dump-files.html)
+ [snaplock legal-hold dump-litigations](https://docs.netapp.com/us-en/ontap-cli-9121/snaplock-legal-hold-dump-litigations.html)
+ [snaplock legal-hold show](https://docs.netapp.com/us-en/ontap-cli-9121/snaplock-legal-hold-show.html)