2. Snapshot Paths

For a snapshottable directory, the path component ".snapshot" is used for accessing its snapshots. Suppose /foo is a snapshottable directory, /foo/bar is a file/directory in /foo, and /foo has a snapshot s0. Then, the path /foo/.snapshot/s0/bar refers to the snapshot copy of /foo/bar. The usual API and CLI can work with the ".snapshot" paths. The following are some examples:

  • Listing all the snapshots under a snapshottable directory: hadoop dfs -ls /foo/.snapshot

  • Listing the files in snapshot s0: hadoop dfs -ls /foo/.snapshot/s0

  • Copying a file from snapshot s0: hadoop dfs -cp /foo/.snapshot/s0/bar /tmp

The name ".snapshot" is now a reserved file name in HDFS so that users cannot create a file/directory with ".snapshot" as the name. If ".snapshot" is used in a previous version of HDFS, it must be renamed before upgrade; otherwise, upgrade will fail.