Backup Strategy: Snapshots, distcp and Protecting Metadata

Big Data and Hadoop Administrator 15 min min read Updated: Nov 17, 2026 Intermediate
Backup Strategy: Snapshots, distcp and Protecting Metadata
Intermediate Topic 1 of 4

Replication Is Not Backup

Common mistake: Three HDFS replicas protect against disk and node failure. They do not protect against accidental deletes, bad jobs that overwrite data, software bugs, ransomware or a whole-site disaster. You need real backups.

What to Back Up

ItemMethodFrequency
Business data in HDFSSnapshots plus distcp to another cluster or object storageDaily incremental
NameNode metadata (fsimage)hdfs dfsadmin -fetchImage off-hostDaily
Hive metastore databasepg_dump / mysqldump plus DB replicationDaily + binlog/WAL
Ranger policies and DBPolicy export (JSON) plus DB dumpDaily
KMS keysEncrypted copy of keystore, offline copy of master keyOn change
ConfigurationGit repository and manager exportsOn every change
HBase tablesSnapshots + ExportSnapshot / replicationDaily
Kafka topicsReplication (MirrorMaker 2) to another clusterContinuous
Kerberos KDC databasekdb5_util dumpDaily

Define RPO and RTO

TermMeaningExample
RPO (Recovery Point Objective)How much data you can lose24 hours for logs, 1 hour for transactions
RTO (Recovery Time Objective)How long you can be down4 hours for reporting, 15 minutes for serving

Ask data owners to classify data (gold, silver, bronze) so you do not back up scratch data at the same level as financial data.

Snapshot Schedule

bash # cron on an admin host, using a keytab for hdfs D=$(date +%Y%m%d) for p in /data/finance /data/sales /warehouse/tablespace/external/hive; do hdfs dfs -createSnapshot $p daily-$D # keep 14 days OLD=$(date -d "14 days ago" +%Y%m%d) hdfs dfs -deleteSnapshot $p daily-$OLD 2>/dev/null done

Backup to Another Cluster with distcp

DistCp copies data using a MapReduce job, in parallel, from many nodes.

bash # full copy first time hadoop distcp -update -p -m 50 -bandwidth 100 \ hdfs://prod/data/finance hdfs://backup/data/finance # -update: copy only changed files -p: preserve ownership, permissions, replication... # -m: number of mappers -bandwidth: MB/s per mapper # -skipcrccheck if block sizes differ, -delete removes extra files on the target

Incremental distcp with Snapshot Diff

bash # 1. first full copy from snapshot s1, then snapshot the target with the SAME name hadoop distcp -update -p hdfs://prod/data/finance/.snapshot/s1 hdfs://backup/data/finance hdfs dfs -createSnapshot hdfs://backup/data/finance s1 # 2. next day: create snapshot s2 on the source, copy only the differences hdfs dfs -createSnapshot /data/finance s2 hadoop distcp -update -diff s1 s2 -p hdfs://prod/data/finance hdfs://backup/data/finance hdfs dfs -createSnapshot hdfs://backup/data/finance s2
Why this is great: -diff copies only files that changed between two snapshots (including renames and deletes), so the job runs in minutes instead of rescanning billions of files. The target must be unchanged since the matching snapshot.

Backup to Object Storage

bash hadoop distcp -update -m 40 -bandwidth 50 hdfs://prod/data/finance s3a://corp-backup/prod/finance/ # credentials: use IAM roles or Hadoop credential providers, never access keys in commands

Verify Backups

  • Compare counts and sizes: hdfs dfs -count -v on source snapshot and target
  • Compare checksums with distcp (CRC check enabled by default) or hdfs dfs -checksum
  • Check the job's counters: BYTESSKIPPED, FILES_FAILED
  • Alert if a backup does not finish or is older than the RPO
bash hdfs dfs -count -v hdfs://prod/data/finance/.snapshot/s2 hdfs://backup/data/finance hdfs dfs -checksum hdfs://prod/data/finance/.snapshot/s2/part-0001 ; hdfs dfs -checksum hdfs://backup/data/finance/part-0001

Restore Procedures

CaseRestore
User deleted a fileCopy from .snapshot/<name> or .Trash
Directory overwrittendistcp from the snapshot back
Cluster lostBuild new cluster, restore metastore DB and configs, distcp data back from backup cluster
Metastore DB lostRestore dump, point HMS to it, run MSCK REPAIR if needed
NameNode metadata lostUse HA copy or the fetched fsimage, see the metadata lesson
A backup that has never been restored is only a hope: Schedule a restore test every quarter: restore a sample dataset and the metastore into a test environment and check that queries work.
Protect the backup too: Use a different security domain and credentials, immutable snapshots or object lock, and restrict who can delete backups. Ransomware targets backups first.

Conclusion

Replication is not backup. Back up data, metadata, databases, keys and configs, use snapshots with incremental distcp, define RPO and RTO, verify, and test restores regularly.

Quick Summary: snapshots + distcp -diff; fetchImage; DB dumps; test restores.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators