Ok

En poursuivant votre navigation sur ce site, vous acceptez l'utilisation de cookies. Ces derniers assurent le bon fonctionnement de nos services. En savoir plus.

backup

# Backup script starts here.
set -x
#!/bin/bash
# Location of the backup logfile.
DEST=/export/BD/dump/postgres
NAME=dec
CLU_NAME=DOUX
HOSTNAME=toto
# Location to place backups.
backup_dir="$DEST/$CLU_NAME"
logfile="$backup_dir/logfile.log"
touch $logfile
timeslot=`date +%H-%M`
databases=`psql -h /var/run/postgresqlcluster$NAME -p 5435 postgres -q -c "l" | sed -n 4,/eof/p | grep -v lignes) | awk {'print $1'} | grep -v template| grep -v "|"`
TO_C="unix@lulu.fr"
date > $logfile
hostname >> $logfile
for i in $databases; do
    echo "DATABASE $i" >> $logfile
        timeinfo=`date '+%T %x'`
        echo "Backup and Vacuum complete at $timeinfo for time slot $timeslot on database: $i " >> $logfile
    /usr/bin/vacuumdb -z -h/var/run/postgresqlcluster$NAME -p 5435 -U s-cad-postgresdec $i >/dev/null 2>&1
        /usr/bin/pg_dump $i -h /var/run/postgresqlcluster$NAME -p 5435  | gzip > "$backup_dir/postgresql-$i-$timeslot-database.gz"
    echo "taille $databases" >> $logfile
    du -hs $backup_dir/postgresql-$i-$timeslot-database.gz >> $logfile
    echo "" >> $logfile
done
echo "Bonjour,nn DUMP BASE POSTGRES$NAME sur le serveur $HOSTNAME. nnL'équipe Unix & Linux" | mutt -x -s "DUMP BASE DUMP POSTGRES$NAME" -a ${logfile} -c ${TO_C}

Écrire un commentaire

Optionnel