<commit_before>
# Hive Server Backup

The backup script dump the content of the hive database as well as the logs.

    module.exports = []
    module.exports.push require('./server').configure

## Database

    module.exports.push name: "Hive Server # Database", callback: (ctx, next) ->
      {hive_site} = ctx.config.ryba
      username = hive_site['javax.jdo.option.ConnectionUserName']
      password = hive_site['<PASSWORD>']
      {engine, db, hostname, port} = parse_jdbc hive_site['javax.jdo.option.ConnectionURL']
      engines = 
        mysql: ->
          escape = (text) -> text.replace(/[\\"]/g, "\\$&")
          ctx.execute
            cmd: """
            mysqldump \
              -u{username} -p#{password} \
              -h#{hostname} -P#{port} \
              #{db} \
              | gzip > /var/tmp/ryba-hive-db-#{Date.now()}.gz
            """
            code_skipped: 2
          , next
      return next new Error 'Database engine not supported' unless engines[engine]
      engines[engine]()

## Logs

Archive the logs generated by the Hive Server2 and remove them from the log
directory.

    module.exports.push name: "Hive Server # Logs", callback: (ctx, next) ->
      ctx.execute
        cmd: """
        ts=`date +%s`
        mkdir /tmp/ryba-hive-$ts
        cp -rp /var/log/hive/hive-server2.log.* /tmp/ryba-hive-$ts
        tar czf /tmp/ryba-hive-log-#{now}.tgz -C /tmp/ryba-hive-$ts .
        rm -rf /var/tmp/ryba-hive-$ts
        """
      , next

<commit_msg>hive: backup conf example<commit_after>
# Hive Server Backup

The backup script dump the content of the hive database as well as the logs.

    module.exports = []
    module.exports.push require('./server').configure

## Database

    module.exports.push name: "Hive Server # Database", callback: (ctx, next) ->
      {hive_site} = ctx.config.ryba
      username = hive_site['javax.jdo.option.ConnectionUserName']
      password = hive_site['javax.jdo.option.ConnectionPassword']
      {engine, db, hostname, port} = parse_jdbc hive_site['javax.jdo.option.ConnectionURL']
      engines = 
        mysql: ->
          escape = (text) -> text.replace(/[\\"]/g, "\\$&")
          ctx.execute
            cmd: """
            mysqldump \
              -u{username} -p#{password} \
              -h#{hostname} -P#{port} \
              #{db} \
              | gzip > /var/tmp/ryba-hive-db-#{Date.now()}.gz
            """
            code_skipped: 2
          , next
      return next new Error 'Database engine not supported' unless engines[engine]
      engines[engine]()

## Logs

Archive the logs generated by the Hive Server2 and remove them from the log
directory.

    module.exports.push name: "Hive Server # Logs", callback: (ctx, next) ->
      ctx.execute
        cmd: """
        ts=`date +%s`
        mkdir /tmp/ryba-hive-conf-$ts
        cp -rp /var/log/hive/hive-server2.log.* /tmp/ryba-hive-conf-$ts
        tar czf /var/tmp/ryba-hive-log-$ts.tgz -C /tmp/ryba-hive-conf-$ts .
        rm -rf /tmp/ryba-hive-conf-$ts
        """
      , next

## Configuration

Backup the active Hive configuration.

    module.exports.push name: "Hive Server # Configuration", callback: (ctx, next) ->
      ctx.execute
        cmd: """
        ts=`date +%s`
        cp -rp /etc/hive/conf /tmp/ryba-hive-conf-$ts
        tar czf /var/tmp/ryba-hive-conf-#{now}.tgz -C /tmp/ryba-hive-conf-$ts .
        rm -rf /tmp/ryba-hive-conf-$ts
        """
      , next


{'fraction_non_alphanumeric': 0.1469139379889887, 'fraction_numerical': 0.0017386264850767893, 'mean_word_length': 1.9707401032702236, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 15, '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': '215089', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1139, 'n_words': 264}