Managing Snapshots

The File Storage service supports snapshots for data protection of your file system.

Snapshots are a consistent, point-in-time view of your file systems. Snapshots are copy-on-write, and scoped to the entire file system. The File Storage service encrypts all file system and snapshot data at rest. You can take as many snapshots as you need.

For more conceptual information, refer to Snapshots in the File Storage Overview chapter of the Oracle Private Cloud Appliance Concepts Guide.

This section provides instructions for managing file system snapshots.

Listing and Getting Snapshot Details

Using the Compute Web UI

  1. In the navigation menu, under File Storage, click File Systems.

  2. Select the appropriate compartment.

  3. Click the file system name.

  4. In the Resources panel, click Snapshots.

    The file system snapshots are listed.

  5. To get the details for a specific snapshot, click the snapshot name.

Using the OCI CLI

  • Listing Snapshots

    1. Gather the information that you need to run the command:

      • File system OCID (oci fs file-system list)

    2. Run this command.

      Syntax (entered on a single line):

      oci fs snapshot list
      --file-system-id <file-system_OCID>

      Example:

      oci fs snapshot list  \
      --file-system-id ocid1.filesystem.….….….uniqueID
      {
        "data": [
          {
            "defined-tags": {},
            "file-system-id": "ocid1.filesystem.….….….uniqueID
      ",
            "freeform-tags": {},
            "id": "ocid1.snapshot.….….….uniqueID-1",
            "lifecycle-state": "ACTIVE",
            "name": "MySnapshot",
            "time-created": "2021-06-21T17:12:37+00:00"
          }
        ]
          {
            "defined-tags": {},
            "file-system-id": "ocid1.filesystem.….….….uniqueID",
            "freeform-tags": {},
            "id": "ocid1.snapshot.….….….uniqueI-2",
            "lifecycle-state": "ACTIVE",
            "name": "MySnapshot2",
            "time-created": "2021-06-21T17:31:18+00:00"
          }
        ]
      }
  • Getting a Specific Snapshot

    1. Gather the information that you need to run the command:

      • Snapshot OCID (oci fs snapshot list)

    2. Run this command.

      Syntax (entered on a single line):

      oci fs snapshot get  \
      --snapshot-id <snapshot_OCID>

      Example:

       oci fs snapshot get --snapshot-id ocid1.snapshot.….….….uniqueID
      {
        "data": {
          "defined-tags": {},
          "file-system-id": "ocid1.filesystem.….….….uniqueID",
          "freeform-tags": {},
          "id": "ocid1.snapshot.….….….uniqueID",
          "lifecycle-state": "ACTIVE",
          "name": "MySnapshot",
          "time-created": "2021-06-21T17:12:37+00:00"
        },
        "etag": "f38aa070-0f3e-407f-a0b4-9bc841ff3fa4"
      }

Creating a Snapshot

You can create a snapshot of a file system. A snapshot is a point-in-time view of the file system. The snapshot is accessible at .zfs/snapshot/name.

Using the Compute Web UI

  1. In the navigation menu, under File Storage, click File Systems.

  2. Select the appropriate compartment.

  3. Click the file system name.

  4. In the Resources panel, click Snapshots.

  5. Click Create Snapshot.

  6. Enter a name for the snapshot.

    The name is limited to 64 characters and it must be unique among all other snapshots for this file system. The name can't be changed. Avoid entering confidential information.

  7. Click Create Snapshot.

    The snapshot is accessible under the root directory of the file system at .zfs/snapshot/name.

Using the OCI CLI

  1. Gather the information that you need to run the command:

    • File system OCID (oci fs file-system list)

    • Snapshot name of your choice. The name is limited to 64 characters and it must be unique among all other snapshots for this file system. The name can't be changed. Avoid entering confidential information.

  2. Run this command.

    Note:

    This procedure shows the minimum required parameters for this command. For information about optional parameters, run the command with the --help option.

    Syntax (entered on a single line):

    oci fs snapshot create
    --file-system-id <file-system_OCID> 
    --name <snapshot_name>

    Example:

    oci fs snapshot create  \
    --file-system-id ocid1.filesystem.….….….uniqueID  \
    --name "MySnapshot"
    {
      "data": {
        "defined-tags": {},
        "file-system-id": "ocid1.filesystem.….….….uniqueID",
        "freeform-tags": {},
        "id": "ocid1.snapshot.….….….uniqueID",
        "lifecycle-state": "CREATING",
        "name": "MySnapshot",
        "time-created": null
      },
      "etag": "f38aa070-0f3e-407f-a0b4-9bc841ff3fa4"
    }

Accessing a Snapshot on the Mounted File System

When a file system snapshot is created, the snapshot is placed in the file system. If the file system is mounted in a client system, you can access the snapshot on the client system.

The snapshot is accessible in this directory path: <mount-point>/.zfs/snapshot/<snapshot-name>.

Using a UNIX OS

  1. Log into the instance OS that has the mounted the file system from which the snapshot was made.

  2. List the snapshots.

    Syntax:

    ls -la <mount-point>/.zfs/snapshot/

    Example:

    ls -la  /mnt/MyMountPoint/.zfs/snapshot
    total 17
    dr-xr-xr-x. 4 root root 4 Sep  8 15:54 .
    dr-xr-xr-x. 4 root root 4 Sep  1 17:27 ..
    drwxr-xr-x. 4 root root 7 Sep  8 15:53 file-system-FS-snapshot-02
    drwxr-xr-x. 4 root root 6 Sep  1 18:12 file-system-FS-snapshot-01
  3. Change to the directory of a snapshot.

    Example:

    cd /mnt/MyMountPoint/.zfs/snapshot/file-system-FS-snapshot-02
  4. List the contents of the snapshot.

    ls -la
    total 3027
    drwxr-xr-x. 4 root root       7 Sep  8 15:53 .
    dr-xr-xr-x. 4 root root       4 Sep  8 15:54 ..
    -rwxr-xr-x. 1 root root     429 Sep  8 15:53 example1
    drwxr-x---. 2 root sys        3 Sep  1 17:28 .$EXTEND
    drwxr-xr-x. 2 root root       2 Sep  1 18:10 ABC-directory
    -rw-r--r--. 1 root root       0 Sep  1 18:10 xyz-file
    -rw-r--r--. 1 root root 3073219 Sep  1 18:12 zap.zip

Restoring a Snapshot (UNIX-Based Instances)

You can restore individual snapshot files or an entire snapshot using the cp command.

Note:

Optionally, you can use rsync, tar, or another tool that supports NFS to copy your data to another remote location.

Using the Instance OS

  1. Log into the instance OS that has the mounted the file system from which the snapshot was made.

  2. List the snapshots.

    Syntax:

    ls -la <mount-point>/.zfs/snapshot/

    Example:

    ls -la  /mnt/MyMountPoint/.zfs/snapshot
    total 17
    dr-xr-xr-x. 4 root root 4 Sep  8 15:54 .
    dr-xr-xr-x. 4 root root 4 Sep  1 17:27 ..
    drwxr-xr-x. 4 root root 7 Sep  8 15:53 file-system-FS-snapshot-02
    drwxr-xr-x. 4 root root 6 Sep  1 18:12 file-system-FS-snapshot-01
  3. Use the cp command to copy individual snapshot files, or the entire snapshot to a location of your choice.

    Use the -r option when restoring a snapshot that contains subdirectories.

    Example:

    cp -r /mnt/MyMountPoint/.zfs/snapshot/<snapshot_name>/* <destination_directory>

Deleting a Snapshot

There are dependencies between file systems, snapshots, and clones. The appliance will not allow you to delete any resources for which there is a dependency. For details, see File Storage Overview in the Oracle Private Cloud Appliance Concepts Guide.

Using the Compute Web UI

  1. In the navigation menu, under File Storage, click File Systems.

  2. Select the appropriate compartment.

  3. Click the name of the file system where the snapshot resides.

  4. In the Resources panel, click Snapshots.

  5. Click the Actions icon (three dots), and then click Delete.

  6. Confirm the deletion.

Using the OCI CLI

  1. Gather the information that you need to run the command:

    • Snapshot OCID (oci fs snapshot list)

  2. Run this command.

    Syntax (entered on a single line):

    oci fs snapshot delete
    --snapshot-id <snapshot_OCID>

    Example:

    oci fs snapshot delete  \
    --snapshot-id ocid1.snapshot.….….….uniqueID
    Are you sure you want to delete this resource? [y/N]: y