-2

I have downloaded script from here : https://ola.hallengren.com/sql-server-backup.html

Thank you for the SQL Server Backup script, it's creating separate folders & subfolders for each database.

But our project requirement: To place all backup files(Full, diff &log) in the same folder for all Databases in the server.

Please suggest if it is possible to change the maintenance script .

Thank you in advance.

Regards,

chaitu

0

1 Answer 1

2

This is just an example:

exec [dbo].[DatabaseBackup]
@Databases = 'XXX'
,@BackupType = 'FULL'
,@Directory = '\\DESTINATION\sqlbackup$'
,@CopyOnly = 'Y'
,@Compress = 'Y'
,@CheckSum = 'Y'
,@init = 'Y'
,@DirectoryStructure = '{ServerName}${InstanceName}'
,@FileName = '{DatabaseName}.{FileExtension}'
,@logToTable = 'Y'
,@Execute = 'Y'

the key is to use this two options:

,@DirectoryStructure = '{ServerName}${InstanceName}'

,@FileName = '{DatabaseName}.{FileExtension}'

For reference, take a look at https://ola.hallengren.com/sql-server-backup.html#DirectoryStructure

4
  • Thank you for your suggestions. I have passes the null value to DirectoryStucture . Now all backup files are placing on same folder . After set the CleanupTime value to 336 job is failing May 24, 2023 at 21:17
  • Code modified: Modified in two places SET @ CreateJobs = 'Y' SET @ BackupDirectory = NULL SET @ CleanupTime = 336 SET @ OutputFileDirectory = NULL SET @ LogToTable = 'Y' @ DirectoryStructure nvarchar(max) = NULL,--'{ServerName}${InstanceName}{DirectorySeparator}{DatabaseName}{DirectorySeparator}{BackupType}_{Partial}_{CopyOnly}', @ AvailabilityGroupDirectoryStructure nvarchar(max) = NULL,-- , May 24, 2023 at 21:19
  • Error:Procedure dbo.DatabaseBackup, Line 2275 The value for the parameter @ CleanupTime is not supported. Cleanup is not supported if the token {DatabaseName} is not part of the directory. Msg 50000, Level 16, State 6, Server mssql-2019, Procedure dbo.DatabaseBackup, Line 2275 The value for the parameter @ CleanupTime is not supported. Cleanup is not supported if the token {BackupType} is not part of the directory. Msg 50000, Level 16, State 1, Server mssql-2019, Procedure dbo.DatabaseBackup, Line 2275 Process Exit Code 1. The step failed. May 24, 2023 at 21:21
  • as per error message, you have to keep folders and backup type to relay on cleanup feature
    – MBuschi
    May 25, 2023 at 15:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.