'Hbase restore table from snapshot after the table is truncated
I executed below statement in order :
hbase> snapshot 'table1', 'snap_table1'
hbase> disable 'table1'
hbase> truncate 'table1'
hbase> restore_snapshot 'snap_table1'
hbase> scan 'table1'
And when i scan table1, I got 0 row(s) (basically it had 108,415,618 rows)
what happened to the 'snap_table1' and 'table1'?
In addition, I executed below.
table2 is succeeded to restore with snap_table1
hbase> clone_snapshot 'snap_table1' , 'table2'
I am new to Hbase and learning it day by day.
Can you give me resources about detail of snapshot for study?
Thank you!
Solution 1:[1]
I think you should try something like this:
snapshot 'TableName', 'SnapshotName'
.... delete old / create new / or truncate the table, and then:
clone_snapshot 'SnapshotName', 'TableName'
Also, keep in mind, that if you use just the truncate command, the table region split structure will be destroyed (i.e. the empty table will have just one new region). If you want to preserve the old region structure, use truncate_preserve instead. If you want to experiment with these options, use the describe command to see the difference in the resultant tables.
Solution 2:[2]
Drop the table 'table1' instead of Truncate it.
And restore_snapshot it from 'snap_table1'
It works for me.
hbase> disable 'table1'
hbase> drop 'table1'
hbase> restore_snapshot 'snap_table1'
I don't know the secret of truncate operation.
But I guess it is same result.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | VS_FF |
| Solution 2 | JovialCoding |
