<commit_before>---
- scm:
    name: env-sync-and-backup_Copy_Data_to_Preview
    scm:
        - git:
            url: <EMAIL>:gds/env-sync-and-backup.git
            branches:
              - master

- job:
    name: Copy_Data_to_Preview
    display-name: Copy_Data_to_Preview
    project-type: freestyle
    description: "This job currently copies all MongoDB databases from Backend. For MySQL, only whitelisted apps have
      their databases copied because several have sensitive data (eg Signonotron, Licensify and ERG)."
    properties:
        - github:
            url: https://github.gds/gds/env-sync-and-backup/
    scm:
      - env-sync-and-backup_Copy_Data_to_Preview
    logrotate:
        artifactNumToKeep: 10
    triggers:
        - timed: 'H 5 * * *'
    builders:
        - shell: |
            set -eu

            cd "${WORKSPACE}"

            echo "Putting in the real MySQL root password"
            sed -i.bak "s/MYSQL_SRC_ROOT_PW=PLACEHOLDER/MYSQL_SRC_ROOT_PW='<%= @mysql_src_root_pw %>'/g" scripts/sync-mysql.sh
            sed -i "s/MYSQL_DST_ROOT_PW=PLACEHOLDER/MYSQL_DST_ROOT_PW='<%= @mysql_dst_root_pw %>'/g" scripts/sync-mysql.sh

            echo "Putting in the real Postgresql env-sync password"
            sed -i.bak "s/PG_SRC_ENV_SYNC_PW=PLACEHOLDER/PG_SRC_ENV_SYNC_PW='<%= @pg_src_env_sync_pw %>'/" scripts/sync-postgresql.sh
            sed -i "s/PG_DST_ENV_SYNC_PW=PLACEHOLDER/PG_DST_ENV_SYNC_PW='<%= @pg_dst_env_sync_pw %>'/" scripts/sync-postgresql.sh

            echo "Running Data Sync"
            bash sync production preview

        - shell: |
            echo "Triggering post-sync job on deploy.preview.alphagov.co.uk"
            curl -f -XPOST https://ci_alphagov:<%= @ci_alphagov_api_key %>@deploy.<EMAIL>/job/Data_Sync_Complete/build -d token=<%= @ci_alphagov_api_token %> --data-urlencode json="{}"
    wrappers:
        - ansicolor:
            colormap: xterm<commit_msg>Only copy data to preview on weekdays<commit_after>---
- scm:
    name: env-sync-and-backup_Copy_Data_to_Preview
    scm:
        - git:
            url: <EMAIL>:gds/env-sync-and-backup.git
            branches:
              - master

- job:
    name: Copy_Data_to_Preview
    display-name: Copy_Data_to_Preview
    project-type: freestyle
    description: "This job currently copies all MongoDB databases from Backend. For MySQL, only whitelisted apps have
      their databases copied because several have sensitive data (eg Signonotron, Licensify and ERG)."
    properties:
        - github:
            url: https://github.gds/gds/env-sync-and-backup/
    scm:
      - env-sync-and-backup_Copy_Data_to_Preview
    logrotate:
        artifactNumToKeep: 10
    triggers:
        - timed: 'H 5 * * 1-5'
    builders:
        - shell: |
            set -eu

            cd "${WORKSPACE}"

            echo "Putting in the real MySQL root password"
            sed -i.bak "s/MYSQL_SRC_ROOT_PW=PLACEHOLDER/MYSQL_SRC_ROOT_PW='<%= @mysql_src_root_pw %>'/g" scripts/sync-mysql.sh
            sed -i "s/MYSQL_DST_ROOT_PW=PLACEHOLDER/MYSQL_DST_ROOT_PW='<%= @mysql_dst_root_pw %>'/g" scripts/sync-mysql.sh

            echo "Putting in the real Postgresql env-sync password"
            sed -i.bak "s/PG_SRC_ENV_SYNC_PW=PLACEHOLDER/PG_SRC_ENV_SYNC_PW='<%= @pg_src_env_sync_pw %>'/" scripts/sync-postgresql.sh
            sed -i "s/PG_DST_ENV_SYNC_PW=PLACEHOLDER/PG_DST_ENV_SYNC_PW='<%= @pg_dst_env_sync_pw %>'/" scripts/sync-postgresql.sh

            echo "Running Data Sync"
            bash sync production preview

        - shell: |
            echo "Triggering post-sync job on deploy.preview.alphagov.co.uk"
            curl -f -XPOST https://ci_alphagov:<%= @ci_alphagov_api_key %>@deploy.preview.alphag<EMAIL>.uk/job/Data_Sync_Complete/build -d token=<%= @ci_alphagov_api_token %> --data-urlencode json="{}"
    wrappers:
        - ansicolor:
            colormap: xterm
{'fraction_non_alphanumeric': 0.11074083568315816, 'fraction_numerical': 0.002050756216354781, 'mean_word_length': 2.428822495606327, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 4, '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': '1568309', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1356, 'n_words': 272}