Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
This article describes how to configure the media retention
server configuration option in SQL Server by using SQL Server Management Studio or Transact-SQL. 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.
If you use the backup medium before the set number of days has passed, SQL Server issues a warning message. SQL Server doesn't issue a warning unless you change the default.
This option is an advanced option and should be changed only by an experienced database administrator or certified SQL Server professional.
The media retention
option can be overridden by using the RETAINDAYS clause of the BACKUP statement.
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.
In Object Explorer, right-click a server and select Properties.
Select the Database settings node.
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.
Connect to the Database Engine.
From the Standard bar, select New Query.
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.
The setting takes effect immediately without restarting the server.
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayTraining
Module
Configure SQL Server resources for optimal performance - Training
Configure SQL Server resources for optimal performance
Certification
Microsoft Certified: Azure Database Administrator Associate - Certifications
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.
Documentation
Set the expiration date on a backup (SQL Server) - SQL Server
This article shows you how to set the expiration date on a backup in SQL Server by using SQL Server Management Studio or Transact-SQL.
Copy-only backups - SQL Server
A copy-only backup is a SQL Server backup that is independent of the sequence of SQL Server backups. It doesn't affect how later backups are restored.
Enable or disable backup checksums during backup or restore (SQL Server) - SQL Server
This article shows you how to enable or disable backup checksums for a database in SQL Server by using SQL Server Management Studio or Transact-SQL.