#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
##### configure start #####
couchbase_host=""
couchbase_user="admin"
couchbase_pwd="admin"
bucket_name_prefix="product_"
couchbase_bin_dir="/opt/couchbase/bin"
export_dir=$(pwd)
##### configure end #####
begin_time=`date +%s`
quantity=$1
if [ "$quantity" = "" ]; then
quantity=3
fi
if [ "$2" != "" ]; then
export_dir=$2
fi
locales=("de_de" "fr_fr" "nl_nl" "it_it" "en_gb" "sv_se" "au_au" "us_us" "de_at" "nl_be" "fr_be" "pl_pl" "es_es" "fr_ch" "de_ch" "pt_pt" "el_gr" "da_dk" "en_ie" "fi_fi" "hu_hu" "nb_no" "cs_cz" "ro_ro" "bg_bg" "sk_sk" "hr_hr" "sl_si" "lt_lt" "et_ee" "lv_lv")
i=1
while :
do
chunk_locales=${locales[@]:$((($i - 1) * $quantity)):$quantity}
if [[ "$chunk_locales" = "" ]]; then
break
fi
for locale in ${chunk_locales}; do
{
bucket_name="${bucket_name_prefix}${locale}"
echo "Export bucket:" $bucket_name
${couchbase_bin_dir}/cbexport json -c couchbase://${couchbase_host} -u ${couchbase_user} -p ${couchbase_pwd} -b "${bucket_name}" -o "${export_dir}/${bucket_name}.json" -f lines
}&
done
sleep 2
wait
let i++
done
wait
end_time=`date +%s`
echo "Total time:" $((($end_time-$begin_time)/60)) "m" $((($end_time-$begin_time)%60)) "s"
echo "done!"