Phoenix backup via HBase snapshots: capturing secondary indexes and SYSTEM.CATALOG in one consistent restore
0 reputation · 13 Jan 2022, 22:35 UTC
0 reputation · 13 Jan 2022, 22:35 UTC
We use Apache Phoenix (5.x) on HBase 2.x and want a documented backup strategy based on HBase snapshots. The goal is a single restore procedure that brings back user tables, their Phoenix secondary indexes, and the SYSTEM.* catalog tables together, so that a restored table is queryable with correct schema and usable indexes.
The uncertainty is around consistency boundaries. Phoenix indexes live as separate HBase tables, and the catalog holds the schema metadata, so a snapshot of only the data table seems insufficient. But taking several snapshots at slightly different times may leave the data table and its index tables out of sync if writes are in flight. It is also unclear whether clone_snapshot (fast, same cluster) or restore_snapshot plus ExportSnapshot (off-cluster copy) is the right choice for a disaster-recovery RPO, given that snapshots only capture data at snapshot time.
Questions:
35275 reputation · 14 Jan 2022, 07:28 UTC
There is no native, atomic HBase snapshot that spans multiple tables unless you use HBase table‑group snapshots (available in HBase 2.5+). Without table‑group support you must pause writes (or stop DDL) while you snapshot the Phoenix data table, each of its index tables, and SYSTEM.CATALOG with the same snapshot name.
Likely explanation: If your cluster runs HBase 2.5 or newer and you have defined a table group that contains the data table, all its index tables, and SYSTEM.CATALOG, a single group snapshot will capture a consistent view without stopping traffic.
Confirmed facts: HBase snapshots are table‑level objects. Phoenix stores each secondary index as a separate HBase table (e.g., MYTABLE_IDX_1) and keeps schema metadata in SYSTEM.CATALOG. Taking independent snapshots at different times can leave the data table and its indexes out of sync if writes are in flight.
hbase shell
> describe 'MYTABLE'
> SELECT INDEX_NAME FROM SYSTEM.INDEX WHERE TABLE_NAME='MYTABLE';disable in HBase shell) and flush memstores:
hbase shell
> disable 'MYTABLE'
> flush 'MYTABLE'
> # repeat disable/flush for each index table discovered above
> disable 'SYSTEM.CATALOG'
> flush 'SYSTEM.CATALOG'phoenix_backup_2026_10_14):
hbase shell
> snapshot 'MYTABLE', 'phoenix_backup_2026_10_14'
> snapshot 'MYTABLE_IDX_1', 'phoenix_backup_2026_10_14'
> snapshot 'MYTABLE_IDX_2', 'phoenix_backup_2026_10_14'
> snapshot 'SYSTEM.CATALOG', 'phoenix_backup_2026_10_14'hbase shell
> enable 'MYTABLE'
> # repeat enable for each index table and SYSTEM.CATALOGhbase shell
> snapshot -listACTIVE in SYSTEM.INDEX:
SELECT * FROM SYSTEM.INDEX WHERE TABLE_NAME='MYTABLE';EXPLAIN on a selective query that should use the index and confirm the plan shows an INDEX SCAN (or RANGE SCAN) for the expected index name:
EXPLAIN SELECT * FROM MYTABLE WHERE COLUMN1 = 'value';For disaster recovery or migration, export each snapshot to a shared location and import them on the target cluster.
hbase shell
> export_snapshot 'phoenix_backup_2026_10_14', '/mnt/backup/phoenix_backup_2026_10_14'hbase shell
> restore_snapshot 'phoenix_backup_2026_10_14'ALTER TABLE … REBUILD INDEX or update catalog compatibility after restore.Do you have HBase 2.5 or newer and have you defined a table group that includes the data table, all its index tables, and SYSTEM.CATALOG? If yes, you can skip the write‑pause step and take a single group snapshot; otherwise, follow the pause‑and‑snapshot procedure above.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.