<commit_before>#!/usr/bin/env bash

now=$(date '+%Y-%m-%d-%H-%M')
BACKUP_PATH="/var/lib/postgresql/backup/"
BACKUP_FILE="${BACKUP_PATH}backup_postgresql_${now}.sql"
echo "---> PG dumping - ${now}: ${BACKUP_FILE}"
sudo docker exec -it postgres sh -c "mkdir -p $BACKUP_PATH"
sudo docker exec -it postgres sh -c "/usr/lib/postgresql/13/bin/pg_dump -U newsblur -h 127.0.0.1 -Fc newsblur > $BACKUP_FILE"


echo " ---> Uploading postgres backup to S3"
sudo docker run --user 1000:1001 --rm \
    -v /srv/newsblur:/srv/newsblur \
    --network=host \
    newsblur/newsblur_python3 \
    python /srv/newsblur/utils/backups/backup_psql.py $BACKUP_FILE

# Don't delete backup since the backup_mongo.py script will rm them
## rm /opt/mongo/newsblur/backup/backup_mongo_${now}.tgz
## rm /opt/mongo/newsblur/backup/backup_mongo_${now}
echo " ---> Finished uploading backups to S3"<commit_msg>Paths are in different environments.<commit_after>#!/usr/bin/env bash

now=$(date '+%Y-%m-%d-%H-%M')
BACKUP_PATH="/var/lib/postgresql/backup/"
UPLOAD_PATH="/srv/newsblur/backups/"
BACKUP_FILENAME="backup_postgresql_${now}.sql"
BACKUP_FILE="${BACKUP_PATH}${BACKUP_FILENAME}"
UPLOAD_FILE="${UPLOAD_PATH}${BACKUP_FILENAME}"
echo "---> PG dumping - ${now}: ${BACKUP_FILE}"
sudo docker exec -it postgres sh -c "mkdir -p $BACKUP_PATH"
sudo docker exec -it postgres sh -c "/usr/lib/postgresql/13/bin/pg_dump -U newsblur -h 127.0.0.1 -Fc newsblur > $BACKUP_FILE"


echo " ---> Uploading postgres backup to S3"
sudo docker run --user 1000:1001 --rm \
    -v /srv/newsblur:/srv/newsblur \
    --network=host \
    newsblur/newsblur_python3 \
    python /srv/newsblur/utils/backups/backup_psql.py $UPLOAD_FILE

# Don't delete backup since the backup_mongo.py script will rm them
## rm /opt/mongo/newsblur/backup/backup_mongo_${now}.tgz
## rm /opt/mongo/newsblur/backup/backup_mongo_${now}
echo " ---> Finished uploading backups to S3"
{'fraction_non_alphanumeric': 0.16140904311251314, 'fraction_numerical': 0.019978969505783387, 'mean_word_length': 4.047745358090186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2867792', 'n_tokens_mistral': 782, 'n_tokens_neox': 711, 'n_words': 156}