Retaining Your Files

You cannot remove a retained file until its retention period expires. You can use the default retention period or specify your own retention period a the time that you retain a file.

Use one of the following methods to specify the retention period for a file:

  • rtime property - Specify the date and time at which you want the retention period to end in one of the following ways:

    • touch -R filename - Changes the retention period of the specified file to the current date and time plus the default retention period.

      If you use the touch -R command to specify a date and time, the specified value becomes the end of the retention period.

      You can use the touch -R command to extend the retention period of a retained file by specifying a date and time in the future. You can also use the touch -t and touch -f commands to specify a future date and time. Note that you cannot shorten the retention period of a retained file.

      Use this command only when the ZFS file system is local to the Oracle Solaris system.

      You can specify the retention period for a file by using the touch command. These commands enable you to set the atime property value to a future date and time before you make the file read-only:

      • touch -R MMDDhhmm[YY] filename

      • touch -a MMDDhhmm[YY] filename

      Note:

      If you do not specify an atime property value, the file's retention period is specified by the retention.period.default property value.
    • chmod a-w filename or chmod ugo-w filename - Removes all write permissions from the file, which triggers file retention.

      These commands use the current date and time plus the default retention period unless atime is set to a future date and time. In that case, these commands use the atime value.

      Use these commands only when the ZFS file system is local or NFS mounted.

    • chmod S+cR filename or chmod S+vreadonly filename - Sets the readonly file attribute on the file over SMB, which triggers file retention.

      These commands use the current date and time plus the default retention period unless atime is set to a future date and time. In that case, these commands use the atime value.

      When a file's retention period ends, the readonly attribute is removed. At that time, you can retain the file again by specifying a new retention period.

  • min and max ZFS properties - Specifies the minimum and maximum values that limit the retention period.

    If you do not specify a time with the touch command, remove write permissions, or set the readonly attribute on the file, files are retained for the default retention period.

    The retention.period.min and retention.period.max property values serve as limits on both the default retention period and for how long you can use touch -R to retain a file.

    Alternately, you can use the access time (atime) as the retention period. When you retain a file, its retention period is restricted to a range between the min and max property values. So, if a retention period that exceeds the range, the period is limited by the min and max property values.

    The atime that you set on a file by using touch -a command adheres to the time range restrictions only if its retained atime value is set to off. For example:

    # zfs set atime=off filesystem

    Optionally, using the min and max method automatically retains files that have remained unmodified for the default retention period.

    You can use the touch -a and touch -R commands to retain a file in a retained ZFS file system. When run on file systems that have file retention disabled, touch -a sets the atime property value and touch -R generates an error.