#!/usr/bin/env ruby

tables_to_backup = <%= @hbase[:weekly_backup_tables].to_a.inspect %>

date             = Time.now.strftime("+%Y%m%d")

export_dir       = "<%= @hbase[:backup_location] %>/#{date}"
hadoop_classpath = "HADOOP_CLASSPATH=/usr/lib/hbase/hbase.jar:/usr/lib/zookeeper/zookeeper.jar:/usr/lib/hbase/lib/guava-r05.jar:/usr/lib/hbase/conf"

tables_to_backup.each do |table|
  system("sudo -u hbase #{hadoop_classpath} hadoop jar <%= @hbase[:home_dir] %>/hbase.jar export #{table} #{export_dir}/#{table} &")
end
