Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rem batch file to autobackup postgres database
- rem Authour- -Saurabh W -Kiran G
- rem edit only part with <>
- @echo off
- REM - backup directory can be a file server share that the PgAgent windows service account has access to
- set BACKUPDIR="<Enter backup path here >"
- set PGHOST="<hostname or address>"
- set PGPORT="<port>"
- set PGUSER="postgres"
- set PGBIN="C:\Program Files\PostgreSQL\9.2\bin\"
- set PGPASSWORD="<enter your database password here>"
- for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
- set dow=%%i
- set month=%%j
- set day=%%k
- set year=%%l
- )
- for /f "tokens=1-3 delims=: " %%i in ("%time%") do (
- set hh=%%i
- set nn=%%j
- )
- %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 >
- %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