Support Questions
Find answers, ask questions, and share your expertise

Are there APIs for HDFS snapshot operations?


Hi all,

1: Is there a API to create snapshot? 
Now we can create snapshot for certain directories in HDFS by command, such as "hdfs dfs -createSnapshot /tmp/sntest snapshot3". 
2: Is there a API to read snapshot files?
After snapshot creation, there is a folder named .snapshot to store snapshot files. Currently I copy them to local then read them. Is there API to read snapshot file content directly without copy to local?
Jack Chen

Re: Are there APIs for HDFS snapshot operations?

Master Guru

For (1): The documenation page at lists all CLI Operations along with an equivalent API call one can use to perform the same. The Java class specifically, is org.apache.hadoop.hdfs.client.HdfsAdmin.


For (2): These snapshot files can be queried like regular HDFS files, so you can run commands such as hadoop fs -cat, etc. on them.