i want to take abckup of fsimage maintaining everything so when something happens then with the use of backup I namenode could be up .
#Put the namenode into safemode
hdfs dfsadmin -safemode enter
#save all the trsactions to namespace
hdfs dfsadmin -saveNamespace
#Download the FSImage of namenode
hdfs dfsadmin -fetchImage <path-forimage>
#Bring the namenode out from safemode
hdfs dfsadmin -safemode leave
#This step is critical
# Navigate to metadata directory
#Extract to the location wherever you want.
tar -cvf /root/nn_backup_data.tar .
Here is the other way
Backing Up and Restoring HDFS Metadata
Backing Up HDFS Metadata Using Cloudera Manager
HDFS metadata backups can be used to restore a NameNode when both NameNode roles have failed. In addition, Cloudera recommends backing up HDFS metadata before a major upgrade.
Minimum Required Role: (also provided by Full Administrator)
This backup method requires you to shut down the cluster.
# tar -cvf /root/nn_backup_data.tar .
You should see output like this:
If there is a file with the extension lock in the NameNode data directory, the NameNode most likely is still running. Repeat the steps, starting by shutting down the NameNode role.
Restoring HDFS Metadata From a Backup
The following process assumes a scenario where both NameNode hosts have failed and you must restore from a backup.