Skip to content

Latest commit

 

History

History
92 lines (60 loc) · 4.16 KB

configure-the-media-retention-server-configuration-option.md

File metadata and controls

92 lines (60 loc) · 4.16 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords
Server configuration: media retention
Learn about the media retention option. See how to use it to specify how long SQL Server retains transaction log and database backups.
rwestMSFT
randolphwest
10/18/2024
sql
configuration
conceptual
backup retention duration [SQL Server]
backup sets [SQL Server], retention duration
media retention option

Server configuration: media retention

[!INCLUDE SQL Server]

This article describes how to configure the media retention server configuration option in [!INCLUDE ssnoversion] by using [!INCLUDE ssManStudioFull] or [!INCLUDE tsql]. The media retention option specifies the length of time to retain each backup set. The option helps protect backups from being overwritten until the specified number of days elapses. After you configure media retention option, you don't have to specify the length of time to retain system backups each time you perform a backup. The default value is 0 days, and the maximum value is 365 days.

Limitations

If you use the backup medium before the set number of days has passed, [!INCLUDE ssNoVersion] issues a warning message. [!INCLUDE ssNoVersion] doesn't issue a warning unless you change the default.

Recommendations

This option is an advanced option and should be changed only by an experienced database administrator or certified [!INCLUDE ssNoVersion] professional.

The media retention option can be overridden by using the RETAINDAYS clause of the BACKUP statement.

Permissions

Execute permissions on sp_configure with no parameters or with only the first parameter are granted to all users by default. To execute sp_configure with both parameters to change a configuration option or to run the RECONFIGURE statement, a user must be granted the ALTER SETTINGS server-level permission. The ALTER SETTINGS permission is implicitly held by the sysadmin and serveradmin fixed server roles.

Use SQL Server Management Studio

  1. In Object Explorer, right-click a server and select Properties.

  2. Select the Database settings node.

  3. Under Backup/Restore, in the Default backup media retention box, type or select a value from 0 through 365 to set the number of days the backup medium will be retained after a database or transaction log backup.

Use Transact-SQL

  1. Connect to the [!INCLUDE ssDE].

  2. From the Standard bar, select New Query.

  3. Copy and paste the following example into the query window and select Execute. This example shows how to use sp_configure to set the value of the media retention option to 60 days.

    USE master;
    GO
    
    EXECUTE sp_configure 'show advanced options', 1;
    GO
    
    RECONFIGURE;
    GO
    
    EXECUTE sp_configure 'media retention', 60;
    GO
    
    RECONFIGURE;
    GO
    
    EXECUTE sp_configure 'show advanced options', 0;
    GO
    
    RECONFIGURE;
    GO

For more information, see Server configuration options.

Follow up: After you configure the media retention option

The setting takes effect immediately without restarting the server.

Related content