<commit_before>#!/bin/bash

if [ "${RETHINKDB_ENV}" == "DEVELOPMENT" ]; then
    echo "ENVIRONMENT: DEV"
    RETHINKDB_HOST=${RETHINKDB_DEV_PORT_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_HOST=${RETHINKDB_DEV_PORT_1_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_PORT=${RETHINKDB_DEV_PORT_28015_TCP_PORT:-${RETHINKDB_PORT}}
    RETHINKDB_PORT=${RETHINKDB_DEV_PORT_1_28015_TCP_PORT:-${RETHINKDB_PORT}}

elif [ "${RETHINKDB_ENV}" == "TEST" ]; then
    echo "ENVIRONMENT: TEST"
    RETHINKDB_HOST=${RETHINKDB_TEST_PORT_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_HOST=${RETHINKDB_TEST_PORT_1_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_PORT=${RETHINKDB_TEST_PORT_28015_TCP_PORT:-${RETHINKDB_PORT}}
    RETHINKDB_PORT=${RETHINKDB_TEST_PORT_1_28015_TCP_PORT:-${RETHINKDB_PORT}}

else
    echo "ENVIRONMENT: PRODUCTION"
    RETHINKDB_HOST=${RETHINKDB_PORT_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_HOST=${RETHINKDB_PORT_1_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_PORT=${RETHINKDB_PORT_28015_TCP_PORT:-${RETHINKDB_PORT}}
    RETHINKDB_PORT=${RETHINKDB_PORT_1_28015_TCP_PORT:-${RETHINKDB_PORT}}
fi

[ -z "${RETHINKDB_HOST}" ] && { echo "=> RETHINKDB_HOST cannot be empty" && exit 1; }
[ -z "${RETHINKDB_PORT}" ] && { echo "=> RETHINKDB_PORT cannot be empty" && exit 1; }

echo "RETHINKDB: HOST: ${RETHINKDB_HOST}, PORT: ${RETHINKDB_PORT}, DB ${RETHINKDB_DB}, EXTRA_OPTS ${EXTRA_OPTS}"

echo "=> Creating backup script"
rm -f /scripts/backups.sh
cat <<EOF >> /scripts/backups.sh
#!/bin/bash

export PATH=$PATH:/usr/local/bin/:/backups/:/scripts/

MAX_BACKUPS=${MAX_BACKUPS}
BACKUP_NAME=\$(date +\%m_\%d_\%Y_\%H_\%M_\%S).tar.gz
BACKUP_CMD="rethinkdb dump -c ${RETHINKDB_HOST}:${RETHINKDB_PORT} -f /backups/\${BACKUP_NAME} ${EXTRA_OPTS}"<commit_msg>Rename the folder to have rethinkdb and environment<commit_after>#!/bin/bash

if [ "${RETHINKDB_ENV}" == "DEVELOPMENT" ]; then
    echo "ENVIRONMENT: DEV"
    RETHINKDB_HOST=${RETHINKDB_DEV_PORT_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_HOST=${RETHINKDB_DEV_PORT_1_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_PORT=${RETHINKDB_DEV_PORT_28015_TCP_PORT:-${RETHINKDB_PORT}}
    RETHINKDB_PORT=${RETHINKDB_DEV_PORT_1_28015_TCP_PORT:-${RETHINKDB_PORT}}

elif [ "${RETHINKDB_ENV}" == "TEST" ]; then
    echo "ENVIRONMENT: TEST"
    RETHINKDB_HOST=${RETHINKDB_TEST_PORT_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_HOST=${RETHINKDB_TEST_PORT_1_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_PORT=${RETHINKDB_TEST_PORT_28015_TCP_PORT:-${RETHINKDB_PORT}}
    RETHINKDB_PORT=${RETHINKDB_TEST_PORT_1_28015_TCP_PORT:-${RETHINKDB_PORT}}

else
    echo "ENVIRONMENT: PRODUCTION"
    RETHINKDB_HOST=${RETHINKDB_PORT_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_HOST=${RETHINKDB_PORT_1_28015_TCP_ADDR:-${RETHINKDB_HOST}}
    RETHINKDB_PORT=${RETHINKDB_PORT_28015_TCP_PORT:-${RETHINKDB_PORT}}
    RETHINKDB_PORT=${RETHINKDB_PORT_1_28015_TCP_PORT:-${RETHINKDB_PORT}}
fi

[ -z "${RETHINKDB_HOST}" ] && { echo "=> RETHINKDB_HOST cannot be empty" && exit 1; }
[ -z "${RETHINKDB_PORT}" ] && { echo "=> RETHINKDB_PORT cannot be empty" && exit 1; }

echo "RETHINKDB: HOST: ${RETHINKDB_HOST}, PORT: ${RETHINKDB_PORT}, DB ${RETHINKDB_DB}, EXTRA_OPTS ${EXTRA_OPTS}"

echo "=> Creating backup script"
rm -f /scripts/backups.sh
cat <<EOF >> /scripts/backups.sh
#!/bin/bash

export PATH=$PATH:/usr/local/bin/:/backups/:/scripts/

MAX_BACKUPS=${MAX_BACKUPS}
BACKUP_NAME=\rethinkdb_${RETHINKDB_ENV,,}_$(date +\%m_\%d_\%Y_\%H_\%M_\%S).tar.gz
BACKUP_CMD="rethinkdb dump -c ${RETHINKDB_HOST}:${RETHINKDB_PORT} -f /backups/\${BACKUP_NAME} ${EXTRA_OPTS}"
{'fraction_non_alphanumeric': 0.15821557218065946, 'fraction_numerical': 0.03768356885563868, 'mean_word_length': 7.0941704035874436, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '2685743', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1539, 'n_words': 176}