• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 805
  • Last Modified:

Postgre Backup Script

I have a postgre database that I am trying to set up automatic backups for. I have written a batch file below that creates a backup for me. The script creates the file fine, but the file is always -kb and does not contain any data. Any help would be greatly appreciated. I am running the batch file under administrator permissions and in the same service account as Postgre. Any help would be greatly appreciated.
@echo off
   for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
     set dow=%%i
     set month=%%j
     set day=%%k
     set year=%%l
   set datestr=%month%_%day%_%year%
   echo datestr is %datestr%
   set BACKUP_FILE=timetrex_%datestr%.backup
   echo backup file name is %BACKUP_FILE%
   SET PGPASSWORD=85473f83b
   echo on
   bin\pg_dump -i -h localhost -p 5433 -U timetrex -F c -b -v -f %BACKUP_FILE% timetrex

Open in new window

1 Solution
earth man2Commented:
Is the script finding the pg_dump executable ?
Try fully qualifying the pg_dump command.eg

Also the database service has to be running for pg_dump to be able to connect to the database.
Can you use command line interface
psql timetrex
before you run the script ?

You are running pg_dump with verbose messages, so if it is being executed you should be getting some idea where it is having a problem
jpadkins49Author Commented:
I changed the file location in the script and that seemed work fine along with using the postgres account rather than the timetrex user. Thanks for the help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now