Recover data from a snapshot
If data is erroneously removed from a directory for which snapshots are available, you can recover the lost data using snapshots. The snapshot ensures that the file blocks corresponding to the deleted files or directories are not removed from the file system. Only the metadata is modified to reflect the deletion.
hdfs dfscommand with the
cpoption to copy the deleted data from the snapshot to the destination directory.
imp_details.xlsfrom a snapshot of the directory (
/data/dir1) that contained the file:
hdfs dfs -cp /data/dir1/.snapshot/s20180412-065533.159/imp_details.xls /data/dir1/