2

I have a problem when I want to delete older backups, I've created with Ola Halengreen scripts.

USE Maintenance
EXECUTE dbo.DatabaseBackup
 @Databases = 'USER_DATABASES',
 @Directory ='/mssql/backup/',
 @DirectoryStructure ='${InstanceName}{DirectorySeparator}{DatabaseName}',
 @Filename='{DatabaseName}_{BackupType}_{Year}{Month}{Day}_{Hour}{Minute}{Second}_{FileNumber}.{FileExtension}',
 @BackupType = 'FULL',
 @Compress = 'Y',
 @CleanupTime = 3

I got the following error message:

The value for the parameter @CleanupTime is not supported. Cleanup is not >supported on Linux.

So far so good, but whats the best way now to delete old Backups without to destroy the Backup chain?

My frist thought was to have a script to delete

#!/bin/sh
find /mssql/backup -name "*.bak" -type f -mtime +3 -exec rm -f {} \;
find /mssql/backup -name "*.trn" -type f -mtime +4 -exec rm -f {} \;

The internal system of the SQL Server Instance will not recognize the clean up after the script was executed. The Backup History in the internal Backup Management will not updated and in the case of a recovery the system wants to have backups which are not existing anymore.

So does anyone have a solution to the problem?

0

I don't know if you already found a solution to your problem, but as of this moment, the extended system stored procedure xp_delete_files is supported on SQL Server 2017 when hosted on a Linux machine.

You can edit Ola's script for database backup and remove the check when the cleanup parameter is being verified, to allow usage on a Linux machine.

I've tried that and the removal of old backups functions just ok, as when run on Windows.

| improve this answer | |
  • Did the "xp_delete_file" came into SQL Server 2017 with an update? Evertime I tried to use this, I got a message, that this stored procedure is not supported. – Necoex Jun 15 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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