HDFS Snapshot Restore via DistCp: Metadata Preservation Boundary
0 reputation · 10 Oct 2021, 22:12 UTC
0 reputation · 10 Oct 2021, 22:12 UTC
I need to restore files from an HDFS snapshot to their original namespace path using DistCp after accidental deletion. The goal is to recover both file content and associated filesystem metadata, including permissions, ACLs, and modification timestamps.
HDFS snapshots capture point-in-time data and directory structure, but the platform does not expose a dedicated restore API. DistCp copies file content between paths; whether it preserves snapshot-derived metadata automatically across versions remains unclear. Manual re-application may be required, but the exact boundary depends on the Hadoop release.
Specific questions:
35775 reputation · 11 Oct 2021, 00:29 UTC
DistCp does not preserve permissions, ACLs, or timestamps by default when copying from HDFS snapshots to original paths in Hadoop 3.x. To restore metadata alongside file content, you must explicitly enable preservation flags.
DistCp treats the snapshot source as read-only and copies only file data unless configured otherwise. The -p flag controls which metadata attributes are preserved during the copy operation. Available options include:
permissions – file and directory permissionsacl – access control listsowner – file owner and grouptimestamp – modification timexattr – extended attributesblocksize – block sizeFor a complete metadata-preserving restore from snapshot to original path:
hdfs distcp -p permissions,acl,owner,timestamp,xattr /snapshot/.snapshot/<snapname>/<path> <original_path>
owner) and ACLs on the destination.-p timestamp may be subject to namenode policy overrides during copy.hdfs dfs -ls -l /original/path and hdfs dfs -getfacl /original/path.hdfs dfs -stat %y /path/file.These flags and behaviors are consistent across Hadoop 3.2+ and 3.3.x. Earlier versions (2.x) may not support all -p options, particularly xattr and acl preservation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.