question

chitrarekhasaha avatar image
chitrarekhasaha asked

Ola Hallengren's script to be used in Task Scheduler

Is there any other alternative available to schedule the task of the user databases using Task Scheduler using Ola Hallengren's Script. The following link is one of the way to schedule task using Job Properties Scheduler

https://www.sqlshack.com/ola-hallengrens-sql-server-maintenance-solution-installation-sql-server-backup-solution/

task
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

KenJ avatar image
KenJ answered

you can definitely run these from task scheduler

from the FAQ page - https://ola.hallengren.com/frequently-asked-questions.html

  1. Download MaintenanceSolution.sql.
  2. Execute MaintenanceSolution.sql. This script creates the stored procedures that you need.
  3. Create cmd files to execute the stored procedures; for example:
    sqlcmd -E -S .\SQLEXPRESS -d master -Q "EXECUTE dbo.DatabaseBackup @Databases = 'USER_DATABASES', @Directory = N'C:\Backup', @BackupType = 'FULL'" -b -o C:\Log\DatabaseBackup.txt
  4. In Windows Scheduled Tasks, create tasks to call the cmd files.
  5. Schedule the tasks.
  6. Start the tasks and verify that they are completing successfully.
15 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

chitrarekhasaha avatar image chitrarekhasaha commented ·

Here are my finding:

Got the error (0*1), did not create the backup file in D:\Backup. Script is as following:

sqlcmd -E -S .\SQLEXPRESS -d master -Q "EXECUTE dbo.DatabaseBackup @Databases = 'IMSAi3old', @Directory = N'D:\Backup', @BackupType = 'FULL'" -b -o D:\Log\DatabaseBackup.txt

Created the task with account DEVWIN\SqlServIntSvc, Action, but the script does not run. Is this specific for SQLExpress.?

From command prompt got the error:

0 Likes 0 ·
6bsse.png (3.6 KiB)
chitrarekhasaha avatar image chitrarekhasaha commented ·

From command prompt got the error:

0 Likes 0 ·
chitrarekhasaha avatar image chitrarekhasaha commented ·


D:\Backup Script>FOBbackup

D:\Backup Script>EXECUTE dbo.DatabaseBackup
'EXECUTE' is not recognized as an internal or external command,
operable program or batch file.
'Databases' is not recognized as an internal or external command,
operable program or batch file.
'Directory' is not recognized as an internal or external command,
operable program or batch file.
'BackupType' is not recognized as an internal or external command,
operable program or batch file.
'Compress' is not recognized as an internal or external command,
operable program or batch file.
'CheckSum' is not recognized as an internal or external command,
operable program or batch file.
'CleanupTime' is not recognized as an internal or external command,
operable program or batch file.

D:\Backup Script>

0 Likes 0 ·
Kev Riley avatar image Kev Riley ♦♦ commented ·

To test direct from command line you need to run the entire command:

sqlcmd -E -S .\SQLEXPRESS -d master -Q "EXECUTE dbo.DatabaseBackup @Databases = 'IMSAi3old', @Directory = N'D:\Backup', @BackupType = 'FULL'" -b -o D:\Log\DatabaseBackup.txt

0 Likes 0 ·
chitrarekhasaha avatar image chitrarekhasaha commented ·

Changed the code a bit to run from command prompt but not successful yet

sqlcmd -S DEVWIN\sqlServIntSvc -d master -Q "EXECUTE dbo.DatabaseBackup @Databases = 'IMSAi3old', @Directory = N'D:\Backup', @BackupType = 'FULL'" -b -o D:\Log

Error log: How do I fix this issue

HResult 0xFFFFFFFF, Level 16, State 1
SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.

0 Likes 0 ·
Show more comments
chitrarekhasaha avatar image
chitrarekhasaha answered

Action Detail:

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

chitrarekhasaha avatar image
chitrarekhasaha answered

Start a program

"D:\Backup Script\FOBbackup.cmd" and no arguments but the job fails.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

KenJ avatar image KenJ commented ·

Not sure without more detail but I saw some suggestions here (https://stackoverflow.com/questions/4437701/run-a-batch-file-with-windows-task-scheduler) that you don't need the double quotes around the path and that you may also need to include your path in the "Start in" text box.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.