Reputation: 1800
I want to delete 30 days older snapshots from HBASE
using shell script. I have written below function but the function will be deleting all snapshots. 30 days older logic also need to be implemented.
deleteSnapshot() {
echo -e "list_snapshots '${NAMESPACE}_${TABLE}'" | hbase shell -n | grep ''${NAMESPACE}'_'${TABLE}'' 2>/dev/null
local RET=$?
if [ ${RET} -eq 0 ]; then
echo "Deleting Snapshot ${NAMESPACE}_${TABLE}"
echo -e "delete_snapshot '${NAMESPACE}_${TABLE}'" | hbase shell -n 2>/dev/null
echo "Successfully deleted Snapshot ${NAMESPACE}_${TABLE}"
fi
}
Help need on that.
Upvotes: 2
Views: 3033
Reputation: 3652
If our snapshot name was: table_name_snapshot_20190701
delete_all_snapshot 'table_name_snapshot_201907.*'
This deletes anything from July. The .
in the name is used as a cutoff for the rest of the snapshot name (which we've replaced with a wildcard *
)
Upvotes: 2
Reputation: 889
You can append the time stamp to the the snapshot name and apply a regex to match only the snapshots that are older than 30 days.
You can refer the document:
Upvotes: 2