#!/bin/sh


export PGPASSWORD=SQL1281

cd /var/scripts/openway_synchro_emailingsolution

echo "`date` : debut de traitement"

echo "`date` : pg_dump des hardbounce"
pg_dump --host=ns207436.ovh.net --data-only --table=general.hardbounce -U postgres fl-network > hardbounce.pg

export PGHOST=127.0.0.1
export PGUSER=flnuser
export PGPASSWORD=fln

echo "`date` : chargement de la table de restoration"
psql --dbname=openway -c 'truncate general.hardbounce'
psql --dbname=openway < hardbounce.pg

echo "`date` : reactivation des profils actifs et desabonnés depuis 60j et + / 0_reactivation.sql"
psql --dbname=openway < 0_reactivation.sql

echo "`date` : mise a jour de la table de travail / 1_agregat.sql"
psql --dbname=openway < 1_agregat.sql

echo "`date` : mise a jour de la table finale des ouvreurs / 2_maj.sql"
psql --dbname=openway < 2_maj.sql

echo "`date` : synchro A7emailing"
php synchro.dc2.php >> synchro.dc2.log 2>&1

echo "`date` : fin de traitement"

