Re: automating backups with windows scheduled tasks and pg_dumpall
Hi Tom
In windows you would need to include the runas command so your bat file
needs to execute the command via runas as in
runas /user:postgres "bin\pg_dumpall.exe -U foo_postgres"
HTH
Martin
----- Original Message -----
From: "Tom Hart" <tomhart@coopfed.org>
To: "Postgres General List" <pgsql-general@postgresql.org>
Sent: Thursday, November 15, 2007 5:07 PM
Subject: [GENERAL] automating backups with windows scheduled tasks and
pg_dumpall
Show quoted text
Hello everybody. I'm having a bit of trouble automating pg_dumpall to do
nightly backups. I have a batch file whose contents are belowSET PGPASSFILE=C:\foo\bar\PG_BACKUP\PGPASSFILE\pgpass.conf
"C:\Program Files\PostgreSQL\8.2\bin\pg_dumpall.exe" -U foo_postgres >
C:\foo\bar\PG_BACKUP\db.outNow this file, when I double click on the .bat, works wonderfully. It
sets the variable correctly, reads the pw file with no problem, and
performs the dump. However when this same bat is built into a scheduled
task (same username, administrator in both cases), even though the task
claims to have completed correctly, I have no evidence of it running,
and it certainly isn't doing the backup.I'm sure many of you have experience in scheduling backups in this
manner (though admittedly a large number of you are probably using cron
in *nix). Is there anything that jumps out at you? Do scheduled tasks
have a problem writing to files with > ? I tried an "echo this is a testtest.txt" and that didn't run either. What's confusing is that
windows is claiming everything ran fine, in under 5 seconds no less (my
db isn't that big, but it takes longer than that to dump the entire
thing). Any ideas?TIA
Thomas R. Hart II
tomhart@coopfed.org---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
Import Notes
Reference msg id not found: 473CC30B.8090809@coopfed.org
Martin Gainty wrote:
Hi Tom
In windows you would need to include the runas command so your bat file
needs to execute the command via runas as in
runas /user:postgres "bin\pg_dumpall.exe -U foo_postgres"HTH
Martin
Actually, schtasks.exe and the windows task scheduler both have this
functionality built in. Also, when using runas.exe from a command
prompt, there's no way to give it a password, thus rendering it
incapable of running unattended in a scheduled task setup. I believe
that's why they placed the runas functionality into schtasks.exe
actually. Thanks anyway.
Thomas R. Hart II
tomhart@coopfed.org