Sample Header Ad - 728x90

pg_dump fails to create a backup when running from System User in Windows Task Scheduler

1 vote
1 answer
1477 views
I am trying to run a pg_dump through a scheduled task in windows. I have two batch files. One creates the task. The other one runs the pg_dump. Even though the pg_dump works with the current user with no problem, I have to run the pg_dump as a System because I want it to run even if the user is not logged on. Unfortunately, to run a task when a user is logged off, you have to run it in System user and that doesn't work for pg_dump. I couldn't see any error. It simply creates an empty backup file and after that, pg_dump keeps on running, blocking future runs. Part of my pg_dump code is the following. %PG_BIN%pg_dump -h %PG_HOST% -p %PG_PORT% -U %PG_USER% -F c -b -v -f %BACKUP_FILE% %DB% Part of my Schtaks code that creates the task. SchTasks /Create /SC MINUTE /mo 30 /RU "SYSTEM" /TN "Database Backup" /TR "%SCRIPT_DIR%backup_db.bat"
Asked by wondim (111 rep)
Apr 17, 2016, 08:57 AM
Last activity: Oct 4, 2022, 02:51 AM