• 0
Sign in to follow this  
Helio Cássio

Aviso Backup postgresql

Question

Bom dia

tem como no scrip abaixo de backup ele envia um e-mail informando quando o backup apresentar algum erro ou não fizer completo?

arquivo.bat

REM Necessario programa forfiles.exe para apagar backups antigos
REM -------------------------------------
REM *** MODIFICAR OS VALORES A SEGUIR ***
REM -------------------------------------
set PGDUMP="C:\Program Files (x86)\PostgreSQL\9.0\bin\pg_dump.exe"
set BACKDIR=c:\bkp
set BACKDAYS=7
set PGUSER=postgres
set PGPASSWORD=
set PGHOST=localhost
set PGDATABASE=autosystem
REM -------------------------------------
REM *** não MODIFICAR DAQUI EM DIANTE ***
REM -------------------------------------
set BACKFILE=dump_autosystem_%date:~-4%%date:~3,2%%date:~0,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.sql.gz
REM Apaga os arquivos mais antigos
forfiles /p %BACKDIR%\ /m *.* /d -%BACKDAYS% /c "cmd /c del @FILE"
REM Executa o backup
echo Backup iniciado em %DATE% %TIME% >>c:\autosystem\log\backup.log
echo Gerando arquivo %BACKDIR%\%BACKFILE% >>c:\autosystem\log\backup.log
%PGDUMP% --compress=9 --file="%BACKDIR%\%BACKFILE%"
echo Backup concluido em %DATE% %TIME% >>c:\autosystem\log\backup.log

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this