<commit_before>#!/bin/bash

# == CONFIG ==
container="influxdb"
format="%s"
# == END CONFIG ==

if [ -z "${1}" ]; then
    echo "[ERROR] No database name given"
    echo "usage: ${0} <database_name>"
    exit 1
fi

dbname=${1}
directory="${dbname}_$(date +"${format}")"
dirname=$(dirname ${0})
path="${dirname}/../backup/${directory}"
archive=${path}.tar.gz

docker exec ${container} sh -c "influxd backup -portable -database ${dbname} -host localhost:8088 /tmp/${directory} && cd /tmp && tar -cf ${directory}.tar.gz ${directory} && rm -r /tmp/${directory}"

if [ $? != 0 ]; then
    echo "[ERROR] dump fail"
    exit 2
fi


echo ${container}-${directory}-${archive}

docker cp ${container}:/tmp/${directory}.tar.gz ${archive}

realpath --relative-to=$(pwd) ${archive}
<commit_msg>remove echo<commit_after>#!/bin/bash

# == CONFIG ==
container="influxdb"
format="%s"
# == END CONFIG ==

if [ -z "${1}" ]; then
    echo "[ERROR] No database name given"
    echo "usage: ${0} <database_name>"
    exit 1
fi

dbname=${1}
directory="${dbname}_$(date +"${format}")"
dirname=$(dirname ${0})
path="${dirname}/../backup/${directory}"
archive=${path}.tar.gz

docker exec ${container} sh -c "influxd backup -portable -database ${dbname} -host localhost:8088 /tmp/${directory} && cd /tmp && tar -cf ${directory}.tar.gz ${directory} && rm -r /tmp/${directory}"

if [ $? != 0 ]; then
    echo "[ERROR] dump fail"
    exit 2
fi

docker cp ${container}:/tmp/${directory}.tar.gz ${archive}

realpath --relative-to=$(pwd) ${archive}

{'fraction_non_alphanumeric': 0.2262532981530343, 'fraction_numerical': 0.014511873350923483, 'mean_word_length': 4.231034482758621, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2812076', 'n_tokens_mistral': 527, 'n_tokens_neox': 515, 'n_words': 141}