Advertisement
Guest User

Untitled

a guest
Mar 16th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. rem batch file to autobackup postgres database
  2.  
  3. rem Authour- -Saurabh W -Kiran G
  4.  
  5. rem edit only part with <>
  6.  
  7. @echo off
  8. REM - backup directory can be a file server share that the PgAgent windows service account has access to
  9. set BACKUPDIR="<Enter backup path here >"
  10. set PGHOST="<hostname or address>"
  11. set PGPORT="<port>"
  12. set PGUSER="postgres"
  13. set PGBIN="C:\Program Files\PostgreSQL\9.2\bin\"
  14. set PGPASSWORD="<enter your database password here>"
  15. for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
  16. set dow=%%i
  17. set month=%%j
  18. set day=%%k
  19. set year=%%l
  20. )
  21.  
  22. for /f "tokens=1-3 delims=: " %%i in ("%time%") do (
  23. set hh=%%i
  24. set nn=%%j
  25. )
  26.  
  27.  
  28.  
  29. %PGBIN%pg_dump -i -h %PGHOST% -p %PGPORT% -U %PGUSER% -F c -b -v -f "%BACKUPDIR%< database name >-%year%%month%%day%%hh%%nn%.compress" < database name >
  30. %PGBIN%pg_dump -i -h %PGHOST% -p %PGPORT% -U %PGUSER% -F t -b -v -f "%BACKUPDIR%< database name >-%year%%month%%day%%hh%%nn%.backup" < database name >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement