In this tutorial, we focus on HDFS snapshots. Common use cases of HDFS snapshots include backups and protection against user errors.

Create a snapshot of HDFS directory:

HDFS directories must be enabled for snapshots in order for snapshots to be created. Steps are:

  • From the Clusters tab -> select HDFS service.
  • Go to the File Browser tab. Select the file directory.

snap1

  • Verify the Snapshottable Path and click Enable Snapshots.

snap2.PNG

With Command line:

Once directory has been enabled for snapshots, take a snapshot.

  • To take a snapshot, click Take Snapshot, specify the name of the snapshot, and click Take Snapshot.

Snap5

The snapshot is added to the snapshot list.

snap8.PNG

With Command line:

Remove the file from snapshot:

Now, let’s “accidentally” remove a file inside the snapshotable directory:

Recover the file from snapshot:

To restore a snapshot, click drop down button near folder name again and select restore from snapshot.

snap9.PNG

Select the snap from and select the restore method.

snap10.PNG

Restore in progress.

snap11.PNG

With Command line:

Recovering from the snapshot is as simple as copying the file.

You can read the content of the file or list the file.

Disable Snapshot:

Try to remove a snapshotable directory by typing a following command as the hdfs user. As expected, the directory can’t be deleted because is snapshottable and it already contains a snapshot. Remove the snapshot first and re-try again.

snap12.PNG

snap13

Delete the snapshot.

snap14.PNG

From command line.

Thanks

Mandy

Leave a Reply