3. Snapshot Operations

Snapshot operations are grouped into the following two categories:

 3.1. Administrator Operations

The operations described in this section require superuser privileges.

  • Allow Snapshots: Allowing snapshots of a directory to be created. If the operation completes successfully, the directory becomes snapshottable.

    • Command:

      hadoop dfsadmin -allowSnapshot $path
    • Arguments:

      Table 4.1. Administrator Operations - Allow Snapshots
      Parameter name Description
      path The path of the snapshottable directory.

      See also the corresponding Java API void allowSnapshot(Path path) in HdfsAdmin.

  • Disallow Snapshots: Disallowing snapshots of a directory to be created. All snapshots of the directory must be deleted before disallowing snapshots.

    • Command:

      hadoop dfsadmin -disallowSnapshot $path
    • Arguments:

      Table 4.2. Administrator Operations - Disallow Snapshots
      Parameter name Description
      path The path of the snapshottable directory.

      See also the corresponding Java API void disallowSnapshot(Path path) in HdfsAdmin.

 3.2. User Operations

The section describes user operations. Note that HDFS superuser can perform all the operations without satisfying the permission requirement in the individual operations.

  • Create Snapshots: Create a snapshot of a snapshottable directory. This operation requires owner privilege to the snapshottable directory.

    • Command:

      hadoop dfs -createSnapshot $path $snapshotName
    • Arguments:

      Table 4.3. User Operations - Create Snapshots
      Parameter name Description
      path The path of the snapshottable directory.
      snapshotName The snapshot name, which is an optional argument. When it is omitted, a default name is generated using a timestamp with the format "'s'yyyyMMdd-HHmmss.SSS", e.g. "s20130412-151029.033".

      See also the corresponding Java API Path createSnapshot(Path path) and Path createSnapshot(Path path, String snapshotName) in FileSystem. The snapshot path is returned in these methods.

  • Delete Snapshots: Delete a snapshot of from a snapshottable directory. This operation requires owner privilege of the snapshottable directory.

    • Command:

      hadoop dfs -deleteSnapshot $path $snapshotName
    • Arguments:

      Table 4.4. User Operations - Delete Snapshots
      Parameter name Description
      path The path of the snapshottable directory.
      snapshotName The snapshot name.

      See also the corresponding Java API void deleteSnapshot(Path path, String snapshotName) in FileSystem.

  • Rename Snapshots: Rename a snapshot. This operation requires owner privilege of the snapshottable directory..

    • Command:

      hadoop dfs -renameSnapshot $path $oldName $newName
    • Arguments:

      Table 4.5. User Operations - Rename Snapshots
      Parameter name Description
      path The path of the snapshottable directory.
      oldName The old snapshot name.
      newName The new snapshot name.

      See also the corresponding Java API void renameSnapshot(Path path, String oldName, String newName) in FileSystem.

  • Get Snapshottable Directory Listing: Get all the snapshottable directories where the current user has permission to take snapshots.

    • Command:

      hadoop lsSnapshottableDir $path $snapshotName
    • Arguments:

      Table 4.6. User Operations - Get Snapshottable Directory Listing
      Parameter name Description
      path The path of the snapshottable directory.
      snapshotName The snapshot name.

    See also the corresponding Java API SnapshottableDirectoryStatus[] getSnapshottableDirectoryListing() in DistributedFileSystem.

  • Get Snapshots Difference Report: Get the differences between two snapshots. This operation requires read access privilege for all files/directories in both snapshots.

    • Command:

      hadoop snapshotDiff $path $fromSnapshot $toSnapshot
    • Arguments:

      Table 4.7. User Operations - Get Snapshots Difference Report
      Parameter name Description
      path The path of the snapshottable directory.
      fromSnapshot The name of the starting snapshot.
      toSnapshot The name of the ending snapshot.