@@ -10,7 +10,7 @@ License: https://ola.hallengren.com/license.html
1010
1111GitHub: https://github.com/olahallengren/sql-server-maintenance-solution
1212
13- Version: 2020 -12-31 18:58:56
13+ Version: 2021 -12-30 19:45:09
1414
1515You can contact me by e-mail at ola@hallengren.com.
1616
@@ -123,7 +123,7 @@ BEGIN
123123 -- // Source: https://ola.hallengren.com //--
124124 -- // License: https://ola.hallengren.com/license.html //--
125125 -- // GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
126- -- // Version: 2020 -12-31 18:58:56 //--
126+ -- // Version: 2021 -12-30 19:45:09 //--
127127 -- --------------------------------------------------------------------------------------------------
128128
129129 SET NOCOUNT ON
@@ -444,6 +444,7 @@ ALTER PROCEDURE [dbo].[DatabaseBackup]
444444@Format nvarchar (max ) = ' N' ,
445445@ObjectLevelRecoveryMap nvarchar (max ) = ' N' ,
446446@ExcludeLogShippedFromLogBackup nvarchar (max ) = ' Y' ,
447+ @DirectoryCheck nvarchar (max ) = ' Y' ,
447448@StringDelimiter nvarchar (max ) = ' ,' ,
448449@DatabaseOrder nvarchar (max ) = NULL ,
449450@DatabasesInParallel nvarchar (max ) = ' N' ,
@@ -458,7 +459,7 @@ BEGIN
458459 -- // Source: https://ola.hallengren.com //--
459460 -- // License: https://ola.hallengren.com/license.html //--
460461 -- // GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
461- -- // Version: 2020 -12-31 18:58:56 //--
462+ -- // Version: 2021 -12-30 19:45:09 //--
462463 -- --------------------------------------------------------------------------------------------------
463464
464465 SET NOCOUNT ON
@@ -706,6 +707,7 @@ BEGIN
706707 SET @Parameters + = ' , @Format = ' + ISNULL (' '' ' + REPLACE (@Format,' '' ' ,' '' '' ' ) + ' '' ' ,' NULL' )
707708 SET @Parameters + = ' , @ObjectLevelRecoveryMap = ' + ISNULL (' '' ' + REPLACE (@ObjectLevelRecoveryMap,' '' ' ,' '' '' ' ) + ' '' ' ,' NULL' )
708709 SET @Parameters + = ' , @ExcludeLogShippedFromLogBackup = ' + ISNULL (' '' ' + REPLACE (@ExcludeLogShippedFromLogBackup,' '' ' ,' '' '' ' ) + ' '' ' ,' NULL' )
710+ SET @Parameters + = ' , @DirectoryCheck = ' + ISNULL (' '' ' + REPLACE (@DirectoryCheck,' '' ' ,' '' '' ' ) + ' '' ' ,' NULL' )
709711 SET @Parameters + = ' , @StringDelimiter = ' + ISNULL (' '' ' + REPLACE (@StringDelimiter,' '' ' ,' '' '' ' ) + ' '' ' ,' NULL' )
710712 SET @Parameters + = ' , @DatabaseOrder = ' + ISNULL (' '' ' + REPLACE (@DatabaseOrder,' '' ' ,' '' '' ' ) + ' '' ' ,' NULL' )
711713 SET @Parameters + = ' , @DatabasesInParallel = ' + ISNULL (' '' ' + REPLACE (@DatabasesInParallel,' '' ' ,' '' '' ' ) + ' '' ' ,' NULL' )
@@ -1250,7 +1252,7 @@ BEGIN
12501252
12511253 -- --------------------------------------------------------------------------------------------------
12521254
1253- IF NOT EXISTS (SELECT * FROM @Errors WHERE Severity >= 16 )
1255+ IF NOT EXISTS (SELECT * FROM @Errors WHERE Severity >= 16 ) AND @DirectoryCheck = ' Y'
12541256 BEGIN
12551257 WHILE (1 = 1 )
12561258 BEGIN
@@ -2551,6 +2553,14 @@ BEGIN
25512553
25522554 -- --------------------------------------------------------------------------------------------------
25532555
2556+ IF @DirectoryCheck NOT IN (' Y' ,' N' ) OR @DirectoryCheck IS NULL
2557+ BEGIN
2558+ INSERT INTO @Errors ([Message], Severity, [State])
2559+ SELECT ' The value for the parameter @DirectoryCheck is not supported.' , 16 , 1
2560+ END
2561+
2562+ -- --------------------------------------------------------------------------------------------------
2563+
25542564 IF @StringDelimiter IS NULL OR LEN (@StringDelimiter) > 1
25552565 BEGIN
25562566 INSERT INTO @Errors ([Message], Severity, [State])
@@ -3711,7 +3721,7 @@ BEGIN
37113721 -- Create directory
37123722 IF @HostPlatform = ' Windows'
37133723 AND (@BackupSoftware <> ' DATA_DOMAIN_BOOST' OR @BackupSoftware IS NULL )
3714- AND NOT EXISTS (SELECT * FROM @CurrentDirectories WHERE DirectoryPath = ' NUL' )
3724+ AND NOT EXISTS (SELECT * FROM @CurrentDirectories WHERE DirectoryPath = ' NUL' OR DirectoryPath IN ( SELECT DirectoryPath FROM @Directories) )
37153725 BEGIN
37163726 WHILE (1 = 1 )
37173727 BEGIN
@@ -3863,7 +3873,8 @@ BEGIN
38633873 END
38643874
38653875 -- Perform a backup
3866- IF NOT EXISTS (SELECT * FROM @CurrentDirectories WHERE DirectoryPath <> ' NUL' AND (CreateOutput <> 0 OR CreateOutput IS NULL )) OR @HostPlatform = ' Linux'
3876+ IF NOT EXISTS (SELECT * FROM @CurrentDirectories WHERE DirectoryPath <> ' NUL' AND DirectoryPath NOT IN (SELECT DirectoryPath FROM @Directories) AND (CreateOutput <> 0 OR CreateOutput IS NULL ))
3877+ OR @HostPlatform = ' Linux'
38673878 BEGIN
38683879 IF @BackupSoftware IS NULL
38693880 BEGIN
@@ -4498,7 +4509,7 @@ BEGIN
44984509 -- // Source: https://ola.hallengren.com //--
44994510 -- // License: https://ola.hallengren.com/license.html //--
45004511 -- // GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
4501- -- // Version: 2020 -12-31 18:58:56 //--
4512+ -- // Version: 2021 -12-30 19:45:09 //--
45024513 -- --------------------------------------------------------------------------------------------------
45034514
45044515 SET NOCOUNT ON
@@ -6400,7 +6411,7 @@ BEGIN
64006411 -- // Source: https://ola.hallengren.com //--
64016412 -- // License: https://ola.hallengren.com/license.html //--
64026413 -- // GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
6403- -- // Version: 2020 -12-31 18:58:56 //--
6414+ -- // Version: 2021 -12-30 19:45:09 //--
64046415 -- --------------------------------------------------------------------------------------------------
64056416
64066417 SET NOCOUNT ON
0 commit comments