From fe9e097259dd09d6938600ccf4ca69c8973eafc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Sun, 3 Mar 2013 08:24:09 +0100 Subject: [PATCH] =?UTF-8?q?[utils/pg=5Fbackups.sh]=20Pour=20backuper=20les?= =?UTF-8?q?=20bases=20PG.=20Est=20appel=C3=A9=20par=20BackuppPC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/pg_backups.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 utils/pg_backups.sh diff --git a/utils/pg_backups.sh b/utils/pg_backups.sh new file mode 100755 index 00000000..2a9627df --- /dev/null +++ b/utils/pg_backups.sh @@ -0,0 +1,31 @@ +#!/bin/bash +PATH="/sbin:/bin:/usr/sbin:/usr/bin" +destination='/pg_backups/' +mail='Roots ' +liste_backups='django etherpad horde roundcube sqlgrey switchs' +probs=0 + +if [ ! -d $destination ]; then + mkdir -p $destination +fi + +for i in $liste_backups; do + if sudo -u postgres pg_dump $i | bzip2 -z > $destination/$i.sql.bz2; then + true; + else + retour="${retour}\nArchivage de la base $i échoué le $(date)..."; + probs=1 + fi; +done + +if [[ $probs -eq 1 ]]; then +(cat << EOF +From: backuppc@crans.org +To: ${mail} +Subject: Backups postgresql foirés +Content-Type: text/plain; charset=UTF-8; + +${retour} +EOF +) | sendmail -t +fi;