[SOLVED] WIndows prefilebackup.bat not executed


I have a client installed on win 2012 R2 Srv.
I need to backup an MSSQ database before the backup so the dump file could include to the backups.
This is what my prefilebackup.bat have:
sqlcmd -S SQLSRV -i d:\scripts\all_database_backup.sql

Executing this file by hand works, dump all database to the d:\sql_backup folder (which is included to the backup directories)

The postfilebackup.bat have this:
del /F /Q d:\sql_backup*

Which would delete the temp sql dump files after the backup.

When i run the incremental or full backup from the server the prefilebackup.bat not run. It did not dump my databases. If i put any file or folder to the sqldump temp dir its deleted after the backup, so the postfilebackup.bat executed correctly after the backup, but the prefilebackup.bat not.

Any ideas why, i did miss something?

My guess would be that it behaves differently owing to database user permissions, which prefilebackup.bat will inherit from the user running it, you when run manually & SYSTEM when UrBackupClientBackend does.

As a sanity check to detect if it’s running & failing rather than not running I’d probably add a second line to do something like ECHO "Test" > D:\Testfile.txt then look for that file during or after a backup runs.

Yes! This was the issue. The service runs by defauls as a LOCAL SYSTEM service.
I changed it to the Domain Admin account and now its working.

Thanks for the tip! :slight_smile: