[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 786
  • 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.

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

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