Snapshot operations are grouped into the following two categories:
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 3.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)
inHdfsAdmin
.
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 3.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)
inHdfsAdmin
.
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 3.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)
andPath createSnapshot(Path path, String snapshotName)
inFileSystem
. 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 3.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)
inFileSystem
.
Rename Snapshots: Rename a snapshot. This operation requires owner privilege of the snapshottable directory..
Command:
hadoop dfs -renameSnapshot $path $oldName $newName
Arguments:
Table 3.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)
inFileSystem
.
Get Snapshottable Directory Listing: Get all the snapshottable directories where the current user has permission to take snapshots.
Command:
hadoop lsSnapshottableDir
Arguments:
Table 3.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()
inDistributedFileSystem
.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 3.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.