Open alenloncaric opened 3 years ago
I found out that in BEFORE_BACKUP on Linux the column CreateOutput in @CurrentDirectories is not set to 0
Beacuse in create directory section it still has a check if the host is Windows:
-- Create directory
IF @HostPlatform = 'Windows'
AND (@BackupSoftware <> 'DATA_DOMAIN_BOOST' OR @BackupSoftware IS NULL)
where i changed this to:
-- Create directory
-- IF @HostPlatform = 'Windows'
-- AND (@BackupSoftware <> 'DATA_DOMAIN_BOOST' OR @BackupSoftware IS NULL)
IF (@BackupSoftware <> 'DATA_DOMAIN_BOOST' OR @BackupSoftware IS NULL)
AND NOT EXISTS(SELECT * FROM @CurrentDirectories WHERE DirectoryPath = 'NUL')
And now it works. Is this ok ?
I have on Linux MSSQL 2019, latest version of the maintenance script.
Script date: Script Date: 11. 05. 2021 07:43:20
I am trying to do a backup and before backup i want to clean older. We backup the VM on hourly basis and some db's are quite large so we are want to delete backups that were already backed up.
I tried the below command on windows and it works ok! On linux it does not delete any file, but it does work when i set AFTER_BACKUP, which in some cases is not possible because of db size and i need free space before.
EXECUTE [dbo].[DatabaseBackup] @Databases = 'master', @Directory = N'/storage/backup/', @BackupType = 'FULL', @Verify = 'Y', @CleanupTime = 2, @CheckSum = 'Y', @LogToTable = 'Y', @CleanupMode = 'BEFORE_BACKUP'
What can i test ? I just did a test:
This is the output of the above command: Date and time: 2021-05-11 07:40:44 Server: bilbo Version: 15.0.4073.23 Edition: Web Edition (64-bit) Platform: Linux Procedure: [master].[dbo].[DatabaseBackup] Parameters: @Databases = 'master', @Directory = '/storage/backup/', @BackupType = 'FULL', @Verify = 'Y', @CleanupTime = 2, @CleanupMode = 'BEFORE_BACKUP', @Compress = NULL, @CopyOnly = 'N', @ChangeBackupType = 'N', @BackupSoftware = NULL, @CheckSum = 'Y', @BlockSize = NULL, @BufferCount = NULL, @MaxTransferSize = NULL, @NumberOfFiles = NULL, @MinBackupSizeForMultipleFiles = NULL, @MaxFileSize = NULL, @CompressionLevel = NULL, @Description = NULL, @Threads = NULL, @Throttle = NULL, @Encrypt = 'N', @EncryptionAlgorithm = NULL, @ServerCertificate = NULL, @ServerAsymmetricKey = NULL, @EncryptionKey = NULL, @ReadWriteFileGroups = 'N', @OverrideBackupPreference = 'N', @NoRecovery = 'N', @URL = NULL, @Credential = NULL, @MirrorDirectory = NULL, @MirrorCleanupTime = NULL, @MirrorCleanupMode = 'AFTERBACKUP', @MirrorURL = NULL, @AvailabilityGroups = NULL, @Updateability = 'ALL', @AdaptiveCompression = NULL, @ModificationLevel = NULL, @LogSizeSinceLastLogBackup = NULL, @TimeSinceLastLogBackup = NULL, @DataDomainBoostHost = NULL, @DataDomainBoostUser = NULL, @DataDomainBoostDevicePath = NULL, @DataDomainBoostLockboxPath = NULL, @DirectoryStructure = '{ServerName}${InstanceName}{DirectorySeparator}{DatabaseName}{DirectorySeparator}{BackupType}{Partial}{CopyOnly}', @AvailabilityGroupDirectoryStructure = '{ClusterName}${AvailabilityGroupName}{DirectorySeparator}{DatabaseName}{DirectorySeparator}{BackupType}{Partial}{CopyOnly}', @FileName = '{ServerName}${InstanceName}{DatabaseName}{BackupType}{Partial}{CopyOnly}{Year}{Month}{Day}{Hour}{Minute}{Second}{FileNumber}.{FileExtension}', @AvailabilityGroupFileName = '{ClusterName}${AvailabilityGroupName}{DatabaseName}{BackupType}{Partial}{CopyOnly}{Year}{Month}{Day}{Hour}{Minute}{Second}_{FileNumber}.{FileExtension}', @FileExtensionFull = NULL, @FileExtensionDiff = NULL, @FileExtensionLog = NULL, @Init = 'N', @Format = 'N', @ObjectLevelRecoveryMap = 'N', @ExcludeLogShippedFromLogBackup = 'Y', @StringDelimiter = ',', @DatabaseOrder = NULL, @DatabasesInParallel = '... Version: 2020-12-31 18:58:56 Source: https://ola.hallengren.com
Date and time: 2021-05-11 07:40:44 Database: [master] State: ONLINE Standby: No Updateability: READ_WRITE User access: MULTI_USER Recovery model: SIMPLE Encrypted: No Is accessible: Yes Differential base LSN: 5423000000040000001 Last log backup LSN: N/A Allocated extent page count: 7176 (56.062500 MB) Modified extent page count: 96 (0.750000 MB)
Your queue no is 2021-05-11 05:40:44.0847945 Date and time: 2021-05-11 07:40:44 Database context: [master] Command: BACKUP DATABASE [master] TO DISK = N'/storage/backup/master_FULL_20210511_074044.bak' WITH CHECKSUM, NO_COMPRESSION Processed 7192 pages for database 'master', file 'master' on file 1. Processed 2 pages for database 'master', file 'mastlog' on file 1. BACKUP DATABASE successfully processed 7194 pages in 0.386 seconds (145.593 MB/sec). Outcome: Succeeded Duration: 00:00:00 Date and time: 2021-05-11 07:40:44
Date and time: 2021-05-11 07:40:44 Database context: [master] Command: RESTORE VERIFYONLY FROM DISK = N'/storage/backup/master/FULL/master_FULL_20210511_074044.bak' WITH CHECKSUM The backup set on file 1 is valid. Outcome: Succeeded Duration: 00:00:00 Date and time: 2021-05-11 07:40:44
Date and time: 2021-05-11 07:40:44
Completion time: 2021-05-11T07:40:46.2001944+02:00
And this are the backups still in the folder master_FULL_20210510_143908.bak master_FULL_20210510_143931.bak master_FULL_20210510_143942.bak master_FULL_20210510_144000.bak master_FULL_20210510_144044.bak master_FULL_20210510_144105.bak master_FULL_20210510_144731.bak master_FULL_20210510_145104.bak master_FULL_20210510_145213.bak master_FULL_20210510_145222.bak master_FULL_20210510_145303.bak master_FULL_20210510_145410.bak master_FULL_20210510_145615.bak master_FULL_20210510_145715.bak master_FULL_20210510_154455.bak master_FULL_20210510_154540.bak master_FULL_20210510_155409.bak master_FULL_20210511_020001.bak master_FULL_20210511_074023.bak master_FULL_20210511_074044.bak master_FULL_20210511_074901.bak
So what can i test more to see why it is not deleting?