[utils/pg_backups.sh] Pour backuper les bases PG. Est appelé par BackuppPC.
This commit is contained in:
parent
b55129ef17
commit
fe9e097259
1 changed files with 31 additions and 0 deletions
31
utils/pg_backups.sh
Executable file
31
utils/pg_backups.sh
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
PATH="/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
destination='/pg_backups/'
|
||||
mail='Roots <roots@crans.org>'
|
||||
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;
|
Loading…
Add table
Add a link
Reference in a new issue