CLI commands to perform snapshot operations
As an administrator, you can enable or disable snapshot creation on a directory. These operations require the superuser privilege. As a user; you can create, delete, or rename snapshots on a directory that has snapshot creation enabled. These operations require either the superuser privilege or the owner privilege on the directory.
Administrator operations
The following table lists the snapshot-related administrator operations that you can on specified directories:
Operation | Command |
---|---|
Enable snapshot creation on a directory | hdfs dfsadmin -allowSnapshot <path> |
Disable snapshot creation on a directory | hdfs dfsadmin -disallowSnapshot <path> |
For more information about these commands, see https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsSnapshots.html#Administrator_Operations.
User operations
The following table lists the user operations that you can perform on snapshots:
Operation | Command |
---|---|
Create snapshots | hdfs dfs -createSnapshot <path>
[<snapshotName>] |
Delete snapshots | hdfs dfs -deleteSnapshot <path>
<snapshotName> |
Rename snapshots | hdfs dfs -renameSnapshot <path> <oldName>
<newName> |
List directories on which snapshot creation is enabled (snapshottable directories) | hdfs lsSnapshottableDir |
List snapshots on a snapshottable directory with their IDs and timestamp of creation | hdfs lsSnapshot |
List differences between contents of snapshots | hdfs snapshotDiff <path> <fromSnapshot>
<toSnapshot> |
For more information about these commands, see https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsSnapshots.html#User_Operations.