Created
February 1, 2012 12:37
-
-
Save constantinoneto/1716834 to your computer and use it in GitHub Desktop.
Backup Postgres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
DATE=`date +%Y%m%d` | |
log_file="/home/backup/base_`date '+%Y%m%d'`.log" | |
sources_dir=/home/backup | |
file_bk=backup-base_`date '+%Y%m%d'`.sql.gz | |
cd /usr/local/postgresql/bin/ | |
/usr/bin/pg_dumpall -v -U minha-base | gzip > /home/backup/base-suse_`date '+%Y%m%d'`.sql.gz | |
cd $sources_dir | |
retbkp=$? | |
if [ $retbkp -gt 0 ] | |
then | |
echo "ERRO: Erro nao foi possivel entrar em $sources_dir ! .................... data =" `date '+%d-%m-%Y %H:%M:%S'` >> $log_file | |
exit 6 | |
else | |
echo "INFO: Entrou no diretorio $sources_dir ! .................... data =" `date '+%d-%m-%Y %H:%M:%S'` >> $log_file | |
fi | |
# Servidor Aplicacoes | |
host="172.20.x.x" | |
user="xxxx" | |
password="xxx" | |
ftp -inv <<EOF | |
open $host | |
user $user $password | |
bin | |
hash | |
put $file_bk | |
bye | |
EOF | |
retbkp=$? | |
if [ $retbkp -gt 0 ] | |
then | |
echo "ERRO: Erro nao foi possivel enviar backup para o host $host ! .................... data =" `date '+%d-%m-%Y %H:%M:%S'` >> $log_file | |
exit 6 | |
else | |
echo "INFO: Envio backup para o host $host ! .................... data =" `date '+%d-%m-%Y %H:%M:%S'` >> $log_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment