-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
650ea22
commit 48f4475
Showing
12 changed files
with
561 additions
and
72 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
/* | ||
Created by BASE\ctrlb using dbatools Export-DbaScript for objects on WORKSTATIONX at 05/18/2017 23:31:48 | ||
See https://dbatools.io/Export-DbaScript for more information | ||
*/ | ||
BEGIN TRANSACTION | ||
DECLARE @ReturnCode INT | ||
SELECT @ReturnCode = 0 | ||
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Maintenance' AND category_class=1) | ||
BEGIN | ||
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Maintenance' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
|
||
END | ||
|
||
DECLARE @jobId BINARY(16) | ||
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'CommandLog Cleanup', | ||
@enabled=1, | ||
@notify_level_eventlog=2, | ||
@notify_level_email=0, | ||
@notify_level_netsend=0, | ||
@notify_level_page=0, | ||
@delete_level=0, | ||
@description=N'Source: https://ola.hallengren.com', | ||
@category_name=N'Database Maintenance', | ||
@owner_login_name=N'sa', @job_id = @jobId OUTPUT | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'CommandLog Cleanup', | ||
@step_id=1, | ||
@cmdexec_success_code=0, | ||
@on_success_action=1, | ||
@on_success_step_id=0, | ||
@on_fail_action=2, | ||
@on_fail_step_id=0, | ||
@retry_attempts=0, | ||
@retry_interval=0, | ||
@os_run_priority=0, @subsystem=N'CmdExec', | ||
@command=N'sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q "DELETE FROM [dbo].[CommandLog] WHERE StartTime < DATEADD(dd,-30,GETDATE())" -b', | ||
@output_file_name=N'$(ESCAPE_SQUOTE(SQLLOGDIR))\CommandLogCleanup_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt', | ||
@flags=0 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
COMMIT TRANSACTION | ||
GOTO EndSave | ||
QuitWithRollback: | ||
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION | ||
EndSave: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
/* | ||
Created by BASE\ctrlb using dbatools Export-DbaScript for objects on WORKSTATIONX at 05/18/2017 23:31:49 | ||
See https://dbatools.io/Export-DbaScript for more information | ||
*/ | ||
BEGIN TRANSACTION | ||
DECLARE @ReturnCode INT | ||
SELECT @ReturnCode = 0 | ||
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Maintenance' AND category_class=1) | ||
BEGIN | ||
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Maintenance' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
|
||
END | ||
|
||
DECLARE @jobId BINARY(16) | ||
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'DatabaseBackup - SYSTEM_DATABASES - FULL', | ||
@enabled=1, | ||
@notify_level_eventlog=2, | ||
@notify_level_email=0, | ||
@notify_level_netsend=0, | ||
@notify_level_page=0, | ||
@delete_level=0, | ||
@description=N'Source: https://ola.hallengren.com', | ||
@category_name=N'Database Maintenance', | ||
@owner_login_name=N'sa', @job_id = @jobId OUTPUT | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'DatabaseBackup - SYSTEM_DATABASES - FULL', | ||
@step_id=1, | ||
@cmdexec_success_code=0, | ||
@on_success_action=1, | ||
@on_success_step_id=0, | ||
@on_fail_action=2, | ||
@on_fail_step_id=0, | ||
@retry_attempts=0, | ||
@retry_interval=0, | ||
@os_run_priority=0, @subsystem=N'CmdExec', | ||
@command=N'sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q "EXECUTE [dbo].[DatabaseBackup] @Databases = ''SYSTEM_DATABASES'', @Directory = N''C:\projects\backups'', @BackupType = ''FULL'', @Verify = ''Y'', @CleanupTime = 24, @CheckSum = ''Y''" -b', | ||
@output_file_name=N'$(ESCAPE_SQUOTE(SQLLOGDIR))\DatabaseBackup_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt', | ||
@flags=0 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
COMMIT TRANSACTION | ||
GOTO EndSave | ||
QuitWithRollback: | ||
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION | ||
EndSave: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
/* | ||
Created by BASE\ctrlb using dbatools Export-DbaScript for objects on WORKSTATIONX at 05/18/2017 23:31:49 | ||
See https://dbatools.io/Export-DbaScript for more information | ||
*/ | ||
BEGIN TRANSACTION | ||
DECLARE @ReturnCode INT | ||
SELECT @ReturnCode = 0 | ||
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Maintenance' AND category_class=1) | ||
BEGIN | ||
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Maintenance' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
|
||
END | ||
|
||
DECLARE @jobId BINARY(16) | ||
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'DatabaseBackup - USER_DATABASES - DIFF', | ||
@enabled=1, | ||
@notify_level_eventlog=2, | ||
@notify_level_email=0, | ||
@notify_level_netsend=0, | ||
@notify_level_page=0, | ||
@delete_level=0, | ||
@description=N'Source: https://ola.hallengren.com', | ||
@category_name=N'Database Maintenance', | ||
@owner_login_name=N'sa', @job_id = @jobId OUTPUT | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'DatabaseBackup - USER_DATABASES - DIFF', | ||
@step_id=1, | ||
@cmdexec_success_code=0, | ||
@on_success_action=1, | ||
@on_success_step_id=0, | ||
@on_fail_action=2, | ||
@on_fail_step_id=0, | ||
@retry_attempts=0, | ||
@retry_interval=0, | ||
@os_run_priority=0, @subsystem=N'CmdExec', | ||
@command=N'sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q "EXECUTE [dbo].[DatabaseBackup] @Databases = ''USER_DATABASES'', @Directory = N''C:\projects\backups'', @BackupType = ''DIFF'', @Verify = ''Y'', @CleanupTime = 24, @CheckSum = ''Y''" -b', | ||
@output_file_name=N'$(ESCAPE_SQUOTE(SQLLOGDIR))\DatabaseBackup_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt', | ||
@flags=0 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
COMMIT TRANSACTION | ||
GOTO EndSave | ||
QuitWithRollback: | ||
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION | ||
EndSave: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
/* | ||
Created by BASE\ctrlb using dbatools Export-DbaScript for objects on WORKSTATIONX at 05/18/2017 23:31:49 | ||
See https://dbatools.io/Export-DbaScript for more information | ||
*/ | ||
BEGIN TRANSACTION | ||
DECLARE @ReturnCode INT | ||
SELECT @ReturnCode = 0 | ||
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Maintenance' AND category_class=1) | ||
BEGIN | ||
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Maintenance' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
|
||
END | ||
|
||
DECLARE @jobId BINARY(16) | ||
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'DatabaseBackup - USER_DATABASES - FULL', | ||
@enabled=1, | ||
@notify_level_eventlog=2, | ||
@notify_level_email=0, | ||
@notify_level_netsend=0, | ||
@notify_level_page=0, | ||
@delete_level=0, | ||
@description=N'Source: https://ola.hallengren.com', | ||
@category_name=N'Database Maintenance', | ||
@owner_login_name=N'sa', @job_id = @jobId OUTPUT | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'DatabaseBackup - USER_DATABASES - FULL', | ||
@step_id=1, | ||
@cmdexec_success_code=0, | ||
@on_success_action=1, | ||
@on_success_step_id=0, | ||
@on_fail_action=2, | ||
@on_fail_step_id=0, | ||
@retry_attempts=0, | ||
@retry_interval=0, | ||
@os_run_priority=0, @subsystem=N'CmdExec', | ||
@command=N'sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q "EXECUTE [dbo].[DatabaseBackup] @Databases = ''USER_DATABASES'', @Directory = N''C:\projects\backups'', @BackupType = ''FULL'', @Verify = ''Y'', @CleanupTime = 24, @CheckSum = ''Y''" -b', | ||
@output_file_name=N'$(ESCAPE_SQUOTE(SQLLOGDIR))\DatabaseBackup_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt', | ||
@flags=0 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
COMMIT TRANSACTION | ||
GOTO EndSave | ||
QuitWithRollback: | ||
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION | ||
EndSave: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
/* | ||
Created by BASE\ctrlb using dbatools Export-DbaScript for objects on WORKSTATIONX at 05/18/2017 23:31:49 | ||
See https://dbatools.io/Export-DbaScript for more information | ||
*/ | ||
BEGIN TRANSACTION | ||
DECLARE @ReturnCode INT | ||
SELECT @ReturnCode = 0 | ||
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Maintenance' AND category_class=1) | ||
BEGIN | ||
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Maintenance' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
|
||
END | ||
|
||
DECLARE @jobId BINARY(16) | ||
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'DatabaseBackup - USER_DATABASES - LOG', | ||
@enabled=1, | ||
@notify_level_eventlog=2, | ||
@notify_level_email=0, | ||
@notify_level_netsend=0, | ||
@notify_level_page=0, | ||
@delete_level=0, | ||
@description=N'Source: https://ola.hallengren.com', | ||
@category_name=N'Database Maintenance', | ||
@owner_login_name=N'sa', @job_id = @jobId OUTPUT | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'DatabaseBackup - USER_DATABASES - LOG', | ||
@step_id=1, | ||
@cmdexec_success_code=0, | ||
@on_success_action=1, | ||
@on_success_step_id=0, | ||
@on_fail_action=2, | ||
@on_fail_step_id=0, | ||
@retry_attempts=0, | ||
@retry_interval=0, | ||
@os_run_priority=0, @subsystem=N'CmdExec', | ||
@command=N'sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q "EXECUTE [dbo].[DatabaseBackup] @Databases = ''USER_DATABASES'', @Directory = N''C:\projects\backups'', @BackupType = ''LOG'', @Verify = ''Y'', @CleanupTime = 24, @CheckSum = ''Y''" -b', | ||
@output_file_name=N'$(ESCAPE_SQUOTE(SQLLOGDIR))\DatabaseBackup_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt', | ||
@flags=0 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
COMMIT TRANSACTION | ||
GOTO EndSave | ||
QuitWithRollback: | ||
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION | ||
EndSave: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
/* | ||
Created by BASE\ctrlb using dbatools Export-DbaScript for objects on WORKSTATIONX at 05/18/2017 23:31:49 | ||
See https://dbatools.io/Export-DbaScript for more information | ||
*/ | ||
BEGIN TRANSACTION | ||
DECLARE @ReturnCode INT | ||
SELECT @ReturnCode = 0 | ||
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Maintenance' AND category_class=1) | ||
BEGIN | ||
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Maintenance' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
|
||
END | ||
|
||
DECLARE @jobId BINARY(16) | ||
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'DatabaseIntegrityCheck - SYSTEM_DATABASES', | ||
@enabled=1, | ||
@notify_level_eventlog=2, | ||
@notify_level_email=0, | ||
@notify_level_netsend=0, | ||
@notify_level_page=0, | ||
@delete_level=0, | ||
@description=N'Source: https://ola.hallengren.com', | ||
@category_name=N'Database Maintenance', | ||
@owner_login_name=N'sa', @job_id = @jobId OUTPUT | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'DatabaseIntegrityCheck - SYSTEM_DATABASES', | ||
@step_id=1, | ||
@cmdexec_success_code=0, | ||
@on_success_action=1, | ||
@on_success_step_id=0, | ||
@on_fail_action=2, | ||
@on_fail_step_id=0, | ||
@retry_attempts=0, | ||
@retry_interval=0, | ||
@os_run_priority=0, @subsystem=N'CmdExec', | ||
@command=N'sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q "EXECUTE [dbo].[DatabaseIntegrityCheck] @Databases = ''SYSTEM_DATABASES''" -b', | ||
@output_file_name=N'$(ESCAPE_SQUOTE(SQLLOGDIR))\DatabaseIntegrityCheck_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt', | ||
@flags=0 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1 | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)' | ||
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback | ||
COMMIT TRANSACTION | ||
GOTO EndSave | ||
QuitWithRollback: | ||
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION | ||
EndSave: | ||
|
Oops, something went wrong.