<commit_before>#!/bin/bash

<% if has_variable?("postgresql_backupdir") -%>
BKPDIR="<%= postgresql_backupdir %>"
<% else -%>
BKPDIR="/var/backups/pgsql/"
<% end -%>
TODAY=$(date +%F)
DAY=$(date +%A |tr 'A-Z' 'a-z')
MONTH=$(date +%B |tr 'A-Z' 'a-z')
TMPDIR=$(mktemp -d -p $BKPDIR) || exit 1

pg_dumpall -U postgres --globals-only |bzip2 > $TMPDIR/ACCOUNT-OBJECTS.$TODAY.dump.bz

for i in `psql -U postgres -c "select datname from pg_database where datname <> 'template0'" -t template1`
    do
        pg_dump -U postgres -C $i |bzip2  > $TMPDIR/$i.$TODAY.dump.bz
    done

test -f $BKPDIR/pgsql_$DAY.tar.gz && rm $BKPDIR/pgsql_$DAY.tar.gz
tar -C $TMPDIR -c -f $BKPDIR/pgsql_$DAY.tar `ls $TMPDIR`
rm -fr $TMPDIR

if [ $(date +%d) == "01" ]; then
    test -f $BKPDIR/pgsql_$MONTH.tar.gz && rm $BKPDIR/pgsql_$MONTH.tar.gz
    cp $BKPDIR/pgsql_$DAY.tar $BKPDIR/pgsql_$MONTH.tar
fi

<commit_msg>postgresql: backup should not block because of a statement timeout.<commit_after>#!/bin/sh

<% if has_variable?("postgresql_backupdir") -%>
BKPDIR="<%= postgresql_backupdir %>"
<% else -%>
BKPDIR="/var/backups/pgsql/"
<% end -%>
TODAY=$(date +%F)
DAY=$(date +%A |tr 'A-Z' 'a-z')
MONTH=$(date +%B |tr 'A-Z' 'a-z')
TMPDIR=$(mktemp -d -p $BKPDIR) || exit 1
export PGOPTIONS='-c statement_timeout=0'

pg_dumpall -U postgres --globals-only |bzip2 > $TMPDIR/ACCOUNT-OBJECTS.$TODAY.dump.bz

for i in `psql -U postgres -c "select datname from pg_database where datname <> 'template0'" -t template1`
    do
        pg_dump -U postgres -C $i |bzip2  > $TMPDIR/$i.$TODAY.dump.bz
    done

test -f $BKPDIR/pgsql_$DAY.tar.gz && rm $BKPDIR/pgsql_$DAY.tar.gz
tar -C $TMPDIR -c -f $BKPDIR/pgsql_$DAY.tar `ls $TMPDIR`
rm -fr $TMPDIR

if [ $(date +%d) == "01" ]; then
    test -f $BKPDIR/pgsql_$MONTH.tar.gz && rm $BKPDIR/pgsql_$MONTH.tar.gz
    cp $BKPDIR/pgsql_$DAY.tar $BKPDIR/pgsql_$MONTH.tar
fi


{'fraction_non_alphanumeric': 0.19391025641025642, 'fraction_numerical': 0.008012820512820512, 'mean_word_length': 3.717884130982368, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '4368300', 'n_tokens_mistral': 896, 'n_tokens_neox': 857, 'n_words': 186}