Database

SQL Server Backup and Restore: T-SQL Full to Log

SQL Server Backup and Restore: T-SQL Full to Log

Protecting a SQL Server database means ensuring that, in the event of a failure, data can be recovered quickly and with minimal loss. This translates into implementing a robust, documented, and, most importantly, regularly tested backup and restore strategy. Conscious use of native SQL Server features, particularly via T-SQL, allows for creating a comprehensive strategy that covers all scenarios, from recovering an entire database to restoring a single transaction. This article explores essential techniques for full, differential, and log backups, their verification, and different restore scenarios, based on best practices and official Microsoft documentation.

Reference versions: SQL Server 2019, 2022 · documentation consulted November 2026

SQL Server Backup and Restore in 60 seconds

-- 1. Set FULL recovery model for point-in-time restore
ALTER DATABASE MyApp SET RECOVERY FULL;
GO

-- 2. Perform a full backup with compression and checksum
BACKUP DATABASE MyApp
TO DISK = 'D:\Backup\MyApp_full.bak'
WITH COMPRESSION, CHECKSUM, STATS = 10;
GO

-- 3. Perform a differential backup (from the last full)
BACKUP DATABASE MyApp
TO DISK = 'D:\Backup\MyApp_diff.bak'
WITH DIFFERENTIAL, COMPRESSION, CHECKSUM;
GO

-- 4. Perform a transaction log backup (for FULL recovery model)
BACKUP LOG MyApp
TO DISK = 'D:\Backup\MyApp_log_20261125_1000.trn'
WITH COMPRESSION, CHECKSUM;
GO

-- 5. Verify backup integrity without restoring it
RESTORE VERIFYONLY
FROM DISK = 'D:\Backup\MyApp_full.bak';
GO

-- 6. Restore a database to another server or with a different name
RESTORE DATABASE MyApp_Test
FROM DISK = 'D:\Backup\MyApp_full.bak'
WITH MOVE 'MyApp_Data' TO 'E:\SQLData\MyApp_Test.mdf',
     MOVE 'MyApp_Log' TO 'E:\SQLLog\MyApp_Test_log.ldf',
     NORECOVERY;
GO

-- 7. Apply a log backup with point-in-time restore
RESTORE LOG MyApp_Test
FROM DISK = 'D:\Backup\MyApp_log_20261125_1000.trn'
WITH STOPAT = '2026-11-25T09:30:00', RECOVERY;
GO

A modern SQL Server infrastructure, especially in enterprise contexts with security, business continuity, and compliance requirements, must rely on a rigorous, documented, and tested backup and restore strategy that consciously leverages the database engine’s native capabilities. Official Microsoft documentation clarifies that backups and restores always operate within the database’s recovery model and that the correct combination of full, differential, and log backups allows for point-in-time recovery in Full and Bulk-logged models, provided the log chain remains intact. At the same time, recent SQL Server versions introduce advanced options for backup compression, modern algorithms like ZSTD, and support for backup and page checksums, which increase the reliability of backup copies and reduce the time and space required, if configured correctly. This article, based exclusively on official documentation and reliable technical sources, provides a factual and up-to-date foundation for designing and implementing, via T-SQL, a complete “full to log” strategy: from choosing the recovery model, to creating compressed full backups with checksums, to differential and log backups, to verifying backups without restoring them, to various restore scenarios (to another server, with a different name, or to a specific point in time) and their scheduling via SQL Server Agent.

Reference versions: SQL Server 2019, 2022 · documentation consulted November 2026

Prerequisites

Before implementing any backup and restore strategy, it is essential to be clear about the SQL Server versions in use and their lifecycle. Microsoft applies a support policy to SQL Server that generally provides at least ten total years: five years of mainstream support and five years of extended support. The official “SQL Server end of support options” page lists, in tabular form, the main versions still relevant in production and their respective end-of-support dates. For example, SQL Server 2016 ended extended support on July 15, 2026, while SQL Server 2017 will end on October 12, 2027. These dates determine the availability of critical security patches and influence architectural choices for backups and migrations. For end-of-life or unsupported products, Microsoft recommends planning migration to newer versions or to managed services like Azure SQL Managed Instance. Adopting good backup practices is not only a measure of resilience but also an essential tool to enable migrations and upgrades, as moving from one version to another often involves full backups and restores on new servers.

It is also crucial to understand that backup compression and other advanced parameters are tied to the SQL Server version and edition. For example, SQL Server 2022 introduced additional parameters such as ALGORITHM and LEVEL to choose between algorithms like MS_XPRESS and ZSTD, balancing backup size and CPU usage. These capabilities must be verified against the version/edition matrix when designing a standardized strategy. Finally, industry regulations (such as ISO 27001, NIS2, GDPR) assume the existence of adequate and tested backup policies. The complete history of all backup and restore operations is stored in the msdb system database, in tables like backupset and restorehistory, facilitating adherence to governance best practices.

Recovery model: SIMPLE or FULL

In SQL Server, all backup and restore operations occur within the context of the database’s recovery model, a configurable property at the individual database level. The recovery model is the mechanism that controls how transactions are logged, whether the log should or can be backed up, and what types of restore operations are available. Essentially, it determines the trade-off between ease of management and the ability to perform granular, point-in-time recoveries, and directly influences the backup strategy, particularly the frequency and nature of transaction log backups. The three supported recovery models are: Simple, Full, and Bulk-logged. The choice among them is a design step that must precede any implementation of T-SQL backup scripts.

It should be noted that the recovery model can be changed over time, but such changes affect the transaction log chain and the possibility of performing a point-in-time restore. Setting a database to the Simple model eliminates the possibility of performing transaction log backups, and consequently, data recovery will always be limited to copies available as full and, if applicable, differential backups. Conversely, Full and Bulk-logged models require the presence of transaction log backups, and the absence of such backups leads to continuous growth of the log file, with potential space and performance issues. This means that switching, for example, from Simple to Full without establishing and maintaining a reliable log backup chain is equivalent to configuring a theoretically more powerful model that is actually ineffective from the perspective of time-based recovery.

Simple recovery model

The Simple recovery model is designed for scenarios where point-in-time recovery is not required and where data loss between the last backup and the time of failure is deemed acceptable. In the Simple model, the transaction log is truncated automatically after the checkpoint, and transaction log backups cannot be performed; consequently, operations that require the log chain, such as point-in-time restore or page restore, are not supported. Any data modified after the last full or differential backup is exposed to loss in the event of database failure, as there is no log backup capable of bridging the gap.

From an operational perspective, with the Simple recovery model, the typical backup strategy consists of periodic full backups, possibly combined with differential backups to reduce the data loss window and restore times. Complete database recovery can be achieved by restoring a full backup and, optionally, a differential backup, without the possibility of adding log backups. This model is less suitable for critical transactional databases but adequate for scenarios such as reporting, test environments, or systems where data can be regenerated in case of loss.

Full recovery model

The Full recovery model represents the most comprehensive option in terms of data recovery capabilities and is recommended for most mission-critical OLTP databases. In this model, all transactions are logged so that it is always possible, provided an uninterrupted chain of log backups is maintained, to restore the database to any point covered by those backups, expressing the target as a date/time or as a transaction marker. The Full model requires transaction log backups because, in the absence of log backups, the log file continues to grow, potentially saturating available space.

From the perspective of restore operations, the Full model allows the following scenarios: complete database restore from a full backup and, optionally, a differential, followed by all subsequent log backups; point-in-time restore, specifying options like STOPAT in RESTORE LOG commands; restore of individual pages or files/filegroups, provided a complete chain of log backups is available up to the current log. This flexibility naturally translates into greater complexity in planning and managing backups, which must include full, differential, and log backups in a coordinated manner.

Bulk-logged recovery model

The Bulk-logged model is a variant of the Full recovery model designed for scenarios where it is necessary to support high-performance bulk load operations by reducing log usage, while maintaining some recovery capability. In the Bulk-logged recovery model, the transaction log still requires backups, but some bulk operations (e.g., bulk insert, select into large tables, index rebuild in bulk mode) are minimally logged, reducing the log space used. In this model, it is also possible to perform log backups and perform full restores, but there are specific limitations for point-in-time restore.

If a log backup contains minimally logged changes, point-in-time restore relative to that backup is not allowed. To recover a database after a minimally logged bulk operation, it is necessary to restore the entire log backup containing those changes, without being able to stop at an intermediate date/time. This makes the Bulk-logged model a compromise choice to be used carefully, often only temporarily during maintenance windows when large bulk operations are performed, and then returning to the Full model.

Synthetic comparison of recovery models

For an overview, it is useful to summarize the main differences between the three recovery models in a table, with respect to relevant aspects for backup and restore:

Feature Simple Full Bulk-logged
Transaction log backup Not supported Required to control growth Required
Point-in-time restore Not supported Fully supported Not allowed if log contains bulk-logged changes
Data recovery Data loss after last backup Potentially complete if log available Some exposure to data loss for bulk minimal logging
File restore Secondary read-only filegroups only Full support Support with restrictions
Page restore Not supported Full support Support with restrictions
Piecemeal restore Secondary read-only filegroups only Full support Support with restrictions

This table is derived from Microsoft documentation descriptions, which detail which scenarios are available for each recovery model. For a DBA, the main message is that the Full model is generally the default choice for critical production databases, the Simple model is appropriate for systems where a few hours of data loss is tolerable or data is easily regenerable, while Bulk-logged is a specific mode to be used in specific cases to optimize bulk operations while maintaining a certain level of recoverability.

Full backup with compression and checksum

The foundation of any data protection strategy in SQL Server is the full database backup, obtained using the T-SQL BACKUP DATABASE statement. This statement allows you to create a full backup of the entire database or one or more files/filegroups, specifying one or more destination devices, which can be disk files, tapes, or URLs (e.g., to Azure Blob Storage).

Basic BACKUP DATABASE T-SQL syntax

The basic syntax for a full database backup is:

BACKUP DATABASE DatabaseName
TO DISK = 'D:\Backup\DatabaseName_full.bak';

In this minimal form, a full backup is created without explicit compression, and the behavior regarding compression depends on the server configuration option backup compression default. Further parameters can be specified in the WITH clause, including COMPRESSION, CHECKSUM, FORMAT, STATS, and many others, which allow controlling the size, reliability, and reporting of the backup. In a production context, it is common practice to avoid systematic use of FORMAT and instead prefer appending new backups to existing media sets, checking via RESTORE HEADERONLY and queries on msdb which backups are present on the device.

Backup compression default and compression options

Backup compression reduces the disk space required and often also improves overall execution times by leveraging the CPU to reduce the amount of data written to relatively slower storage. In SQL Server, compression can be controlled both at the server level, via the backup compression default option, and at the individual backup level, via the COMPRESSION and NO_COMPRESSION options of the BACKUP statement. The backup compression default configuration option is exposed in the sys.configurations view and can be modified via sp_configure; a value of 0 indicates that, by default, the server performs uncompressed backups, while a value of 1 indicates that the server performs compressed backups, unless the BACKUP statement specifies otherwise.

To enable default compression:

EXECUTE sp_configure 'backup compression default', 1;
RECONFIGURE;
GO

At the individual backup level, the syntax provides the generic option:

BACKUP DATABASE App
TO DISK = 'D:\Backup\App_full.bak'
WITH COMPRESSION, CHECKSUM;

For recent versions, particularly SQL Server 2022, the ability to specify the ALGORITHM parameter and the compression LEVEL has been introduced, as in:

BACKUP DATABASE DatabaseName
TO DISK = 'D:\Backup\DatabaseName_full_zstd.bak'
WITH COMPRESSION (ALGORITHM = ZSTD, LEVEL = MEDIUM);

This allows the backup strategy designer to adapt the compression level to hardware characteristics and RTO/RPO requirements, balancing backup speed and size. Read also: PostgreSQL VACUUM: Autovacuum Tuning and Wraparound Risk

Backup checksums and integrity verification

A critical element for backup security is the ability to detect data corruption, both at the page level and at the backup level as a whole. SQL Server supports backup checksums, which are enabled via the CHECKSUM option in the BACKUP statement. Specifying WITH CHECKSUM causes the database engine to verify, for each page, the presence of checksums or torn page detection, if enabled, and generate a checksum for the entire backup. If an invalid checksum page is detected during the backup, the operation fails or proceeds according to the error handling options specified, such as CONTINUE_AFTER_ERROR.

The NO_CHECKSUM option, conversely, explicitly disables the generation and verification of backup-level checksums, even if the database uses page checksums. During a restore, the default behavior is to verify checksums if present, unless NO_CHECKSUM is specified, and the CHECKSUM option on the restore forces verification and causes an error if the backup does not contain checksums. This asymmetry is important: if backups were created without CHECKSUM, a subsequent RESTORE with CHECKSUM will immediately fail, indicating the absence of checksums. To maximize backup reliability, it is advisable to use WITH CHECKSUM in backup scripts, accepting the slight CPU overhead in exchange for the ability to detect corruption at the time of backup creation or verification.

BACKUP DATABASE App
TO DISK = 'D:\Backup\App_full_chk.bak'
WITH COMPRESSION,
     CHECKSUM,
     STATS = 10;

Copy-only full backups

A special case of full backup is the copy-only backup, which documentation defines as a backup that does not interfere with the normal sequence of differential and log backups. A standard full backup modifies the database’s “differential base,” meaning the full backup on which subsequent differential backups will be based; a copy-only full backup, however, is not considered as a base for differentials and does not alter the relationship between other backups. This is particularly useful when ad-hoc backups need to be created, for example, before a migration, a restore test, or an extraordinary operation, without modifying the existing differential backup strategy.

The syntax for a copy-only full backup is:

BACKUP DATABASE Sales
TO DISK = 'E:\BAK\Sales_Copy.bak'
WITH COPY_ONLY;

The same logic applies to copy-only log backups, which do not break the log backup chain used for restore. Microsoft specifies that a copy-only log backup does not truncate the log in the same way as regular log backups and can be used when it is necessary to generate an independent log backup without compromising the regular backup plan. In general, however, copy-only backups should be used sparingly and for specific scenarios, clearly documenting their purpose.

Differential and log backups

Concepts and use of differential backups

A differential backup is designed to capture only the data changed since the last reference full backup, defined as the differential base. A differential backup is always based on the last “non-copy-only” full backup of the database and contains all changes that occurred from that moment until the differential was created. This means that differential backups tend to grow in size over time because they cumulatively include all changes since the last full, until a new full backup is performed that updates the base.

From an operational perspective, using differential backups is a common strategy to reduce the time and space required for backups compared to performing full backups too frequently. A typical strategy involves a weekly full backup and daily differential backups, so that, in case of recovery, only the last differential needs to be applied in addition to the full, instead of a long series of incremental backups. The T-SQL syntax for creating a differential backup is a natural extension of BACKUP DATABASE, with the addition of the WITH DIFFERENTIAL clause:

BACKUP DATABASE App
TO DISK = 'D:\Backup\App_diff.bak'
WITH DIFFERENTIAL, COMPRESSION, CHECKSUM;

It is good practice to combine DIFFERENTIAL with options like COMPRESSION and CHECKSUM to ensure that differentials are both space-efficient and reliable. Differential backups ignore copy-only full backups: the differential base remains the most recent “normal” full backup. Read also: mysqldump Backup: Consistency & MySQL/MariaDB Restore

Transaction log backups in Full and Bulk-logged recovery models

In Full and Bulk-logged recovery models, transaction log backups are fundamental for two reasons: they allow for point-in-time database recovery and limit log file growth. In these two models, the transaction log “continues to grow until a log backup is performed,” and log backup is therefore a mandatory operation for database health maintenance.

The BACKUP LOG statement is used to create a transaction log backup; the basic syntax is:

BACKUP LOG App
TO DISK = 'D:\Backup\App_log.trn';

As with full backups, options such as COMPRESSION and CHECKSUM can be added to optimize space and verify the integrity of log backups. Regular use of log backups prevents the log file from reaching unmanageable sizes and creates the necessary chain for point-in-time restore. For a point-in-time restore, the log chain must be uninterrupted, without “gaps” between various log backups, and the initial full backup must have an endpoint prior to the restore target.

Tail-log backup: capturing the “tail” of the log before restore

A special case of log backup is the tail-log backup, which aims to capture any log records not yet included in a previous log backup (the so-called “tail” of the log), before starting a restore operation that might overwrite the database. The tail-log backup is a measure to prevent data loss and maintain the log chain intact, especially in failure scenarios or when planning to perform a restore on a still-online database.

Two main scenarios require a tail-log backup. In the first, the database is online and a series of restores are planned: it is necessary to start by performing a BACKUP LOG ... WITH NORECOVERY, which puts the database into a “restoring” state, preventing further modifications and ensuring that no subsequent log records are lost. In the second scenario, the database is offline or damaged and cannot start: in this case, WITH NO_TRUNCATE can be used, which behaves similarly to a copy-only log backup and attempts to capture the log even if the database is not fully operational. The NO_TRUNCATE option is recommended only if the database is damaged or offline, and serves to prevent log truncation under conditions where it would not be safe to do so.

Common pitfalls with differential and log backups

Working with differential and log backups introduces a series of potential pitfalls that are good to know and prevent. A first pitfall concerns changing the recovery model: switching from Full to Simple and then back to Full breaks the log chain, making it impossible to use log backups prior to the change for a point-in-time restore, because in the Simple model, the log is no longer preserved for backup. Those managing backup scripts must therefore ensure that recovery model changes are planned, coordinated with new full backups, and accompanied by clear documentation of the new restore chain.

Another pitfall concerns the incorrect use of copy-only backups. As seen, copy-only full backups do not update the differential base. However, if copy-only full backups are performed thinking they will become the new base for differentials, one can find oneself in scenarios where the most recent differential does not apply to the newly created copy-only full but to a previous full, with the risk of confusion and errors during restore. The solution is to know precisely which full is the current differential base and use msdb (tables backupset and backupmediafamily) to determine the correct restore sequence.

A frequent pitfall also concerns the order and completeness of log backups. For a complete restore in Full mode, all log backups must be applied in sequence, without gaps, from the last full or differential up to the desired moment. If an intermediate log backup is missing or corrupted, subsequent logs cannot be applied, and recovery will be limited to the available intact chain, with potential significant data loss. Furthermore, in the Bulk-logged recovery model, if a log backup contains minimally logged bulk operations, point-in-time restore on that backup is not possible: one must restore to the end of that log, losing temporal granularity.

Finally, it should be remembered that some restore scenarios require a tail-log backup before restoring a Full or Bulk-logged database, and omitting this operation can lead to errors or loss of unsaved logs. SQL Server generally requires a tail-log backup before restore, unless the WITH REPLACE or WITH STOPAT option is used for a point in time after the end of the data backup, still accepting the loss of unsaved logs.

Verify a backup without restoring it

Verifying the integrity of a backup is a crucial step to ensure that backup files are actually usable in case of disaster, without necessarily performing a full restore every time. SQL Server offers, for this purpose, the RESTORE VERIFYONLY command, which allows you to verify a backup without restoring it. RESTORE VERIFYONLY checks that the backup set is complete and that all volumes are readable, performing checks on some page header fields (such as page ID) and, if present, checksums; it also verifies the presence of sufficient space on the destination devices, as if a restore were about to be performed.

The basic syntax is very simple:

RESTORE VERIFYONLY
FROM DISK = 'D:\Backup\App_full.bak';
GO

If the backup is considered valid, the database engine returns a success message; otherwise, an error is generated indicating the detected problem. However, it is important to highlight a significant limitation: RESTORE VERIFYONLY does not attempt to verify the structure of the data contained in the backup, and therefore does not guarantee that all pages and application objects are consistent, but is limited to a consistency check of the backup set and checksums, if available. For this reason, Microsoft recommends viewing VERIFYONLY as an important but not definitive indicator of backup reliability.

RESTORE VERIFYONLY supports various options, including CHECKSUM, NO_CHECKSUM, STOP_ON_ERROR, CONTINUE_AFTER_ERROR. The CHECKSUM option specifies that backup checksums must be checked during verification, and that verification must fail if checksums are not present; the NO_CHECKSUM option, on the other hand, disables checksum verification. The STOP_ON_ERROR and CONTINUE_AFTER_ERROR options control behavior in case of error, allowing you to decide whether to stop verification at the first error or attempt to continue.

Other inspection commands: HEADERONLY and FILELISTONLY

In addition to VERIFYONLY, SQL Server provides other “informative” RESTORE commands that do not perform recovery but allow you to consult the metadata contained in the backup. RESTORE HEADERONLY returns information about the backup set header, including data such as the database name, backup start and end date, recovery model, backup type (full, differential, log), and backup set identifier. This is useful for determining, for example, which backups are present in a .bak file containing multiple backups in sequence, or for verifying that the backup actually corresponds to the expected database and time.

RESTORE FILELISTONLY, on the other hand, returns the list of data and log files included in the backup, with their respective logical names and original paths, and is often used before a restore to a different server or with different paths, to construct the necessary MOVE clauses. Read also: Linux: Free Up Disk Space with 12 Commands (SysAdmin Guide 2026) These commands do not verify data integrity but provide essential information for planning and debugging restore operations. In combination with RESTORE VERIFYONLY and information on msdb history tables (backupset and backupmediafamily), they allow for a complete picture of available backups and their content, without modifying databases.

Restore to another server or with a different name

It is often necessary to restore a database to a different server than the original, or with a different name (for example, to create a test or development environment from a production backup). The RESTORE DATABASE statement handles these scenarios using the WITH MOVE clause and the NORECOVERY option.

The WITH MOVE clause is essential when the physical paths of the data (.mdf) and log (.ldf) files on the destination server are different from the original ones (which were recorded in the backup). To find out the logical file names and original paths, you can use RESTORE FILELISTONLY on the backup file. An example of restoring to a different server or with another name is:

RESTORE DATABASE App_Test
FROM DISK = 'D:\Backup\App_full.bak'
WITH MOVE 'App_Data' TO 'E:\SQLData\App_Test.mdf',
     MOVE 'App_Log' TO 'E:\SQLLog\App_Test_log.ldf',
     NORECOVERY;
GO

In this example, App_Test is the new database name. App_Data and App_Log are the logical file names within the backup. E:\SQLData\App_Test.mdf and E:\SQLLog\App_Test_log.ldf are the new physical paths on the destination server. The NORECOVERY option is crucial: it puts the database into a RESTORING state and keeps it in a “non-operational” state, allowing subsequent differential or log backups to be applied. Only after applying the last backup (or the desired log), WITH RECOVERY will be used to bring the database online. If only a full backup is being restored and no other backups are intended to be applied, WITH RECOVERY can be used directly on the RESTORE DATABASE statement to bring the database online immediately after restoration.

Point-in-time recovery with the log

Point-in-time restore is one of the most powerful features offered by the Full recovery model and transaction log backup. It allows you to recover the database exactly as it was at a specified date and time, or up to a transaction marker, minimizing data loss. This scenario requires an uninterrupted chain of backups: a full backup, optionally a differential, and all subsequent log backups up to the desired point in time.

The procedure involves the following steps:

  1. Restore the full backup (and optionally the most recent differential) with the NORECOVERY option to keep the database in RESTORING state.
    RESTORE DATABASE App_Test
    FROM DISK = 'D:\Backup\App_full.bak'
    WITH NORECOVERY;
    GO
  1. Apply log backups in sequence, always with NORECOVERY, up to the log that contains the desired point in time. It is essential to apply them in the chronological order in which they were created.
  1. Apply the last log backup specifying the WITH STOPAT clause and WITH RECOVERY. STOPAT indicates the exact date and time at which to stop the restore, and RECOVERY brings the database online and makes transactions operational.
    RESTORE LOG App_Test
    FROM DISK = 'D:\Backup\App_log.trn'
    WITH STOPAT = '2026-10-26T14:00:00', RECOVERY;
    GO

The typical output will be a success message indicating the restore completed up to the specified point in time.

It is crucial to ensure that all necessary log backup files are available and intact. If a log backup in the chain is missing or corrupted, point-in-time restore will not be possible beyond the break point in the chain. The granularity of point-in-time restore is limited by the frequency of log backups: the more frequently log backups are performed, the more precise the recovery point that can be achieved.

Schedule with SQL Agent

To automate backup and restore operations in SQL Server, the primary tool is SQL Server Agent. SQL Server Agent is a service that runs jobs, which are sequences of steps that can include T-SQL scripts, operating system commands, SSIS packages, or other types of tasks. Scheduling backups via SQL Server Agent ensures that operations are performed regularly and reliably, reducing manual intervention and the risk of errors.

To schedule a daily full backup, a weekly differential, and log backups every 15 minutes, three separate jobs are typically created:

  1. Job for full backup: Contains a T-SQL step that executes the BACKUP DATABASE ... WITH COMPRESSION, CHECKSUM; statement. This job is scheduled to run once a day, for example, at night or on weekends, depending on server load.
  1. Job for differential backup: Contains a T-SQL step with BACKUP DATABASE ... WITH DIFFERENTIAL, COMPRESSION, CHECKSUM;. This job is scheduled to run daily, but at a different time than the full backup, typically after peak activity hours.
  1. Job for transaction log backup: Contains a T-SQL step with BACKUP LOG ... WITH COMPRESSION, CHECKSUM;. This job is the most frequent, scheduled every 15 or 30 minutes, depending on RPO (Recovery Point Objective) requirements and log growth rate. It is essential that this job runs regularly to prevent the transaction log from growing excessively.

Each job should be configured with notifications in case of success or failure (e.g., via email or SQL Server Alerts) and with output logging to dedicated log files to facilitate troubleshooting. SQL Server Agent job management can be done via SQL Server Management Studio (SSMS) or via T-SQL scripts that interact with msdb system tables (msdb.dbo.sysjobs, msdb.dbo.sysjobsteps, msdb.dbo.sysschedules). Read also: Zabbix Agent 2: Installation, Configuration, and Plugins

Common Errors and Troubleshooting

Exact Error or Message Cause Solution
The backup set holds a backup of a database other than the existing 'DatabaseName' database. Attempting to restore a backup of a database with a different name onto an existing database without the REPLACE option. Use RESTORE DATABASE NewDatabaseName FROM DISK='...' WITH MOVE 'LogicalName' TO 'NewPath', REPLACE; to overwrite the existing database or restore with a new name.
The log backup chain is broken. A log backup is missing or corrupted in the sequence, or the recovery model was changed from Full to Simple. Identify the missing or corrupted log backup (RESTORE HEADERONLY). If the recovery model was changed, perform a new full backup and start from there. The restore will be limited to the point before the chain break.
Cannot open backup device 'D:\Backup\DatabaseName_full.bak'. Operating system error 5(Access is denied.). The SQL Server service account does not have write permissions on the backup directory. Grant the SQL Server service account write permissions (or the account running the SQL Agent job) on the specified directory. Also check network permissions if the destination is a UNC path.
The media family on device 'D:\Backup\DatabaseName_full.bak' is incorrectly formed. The backup file is corrupted or is not a valid SQL Server backup file. Retry the backup or use a different backup file. Verify the integrity of the original backup if possible.
The tail of the log for the database "DatabaseName" has not been backed up. Attempting to restore a database in FULL or BULK_LOGGED recovery model without having performed a tail-log backup. Perform a tail-log backup (BACKUP LOG DatabaseName TO DISK='...' WITH NORECOVERY) before the restore, or use WITH REPLACE if you are sure there are no useful logs to save.

Frequently Asked Questions

What is the main difference between a differential backup and a log backup?

A differential backup captures all changes made to the database since the last “normal” full backup. It tends to grow over time until the next full backup. A log backup, available only in Full and Bulk-logged recovery models, captures transactions from the transaction log since the last log or full backup. It is smaller and is performed much more frequently to allow for point-in-time recovery.

Is it possible to restore a database from a full backup without log backups?

Yes, it is possible to restore a database from a full backup (and a differential, if present) without additional log backups. However, in this scenario, the database will be recovered to the state it was in at the time the full (or differential) backup was created. It will not be possible to perform a point-in-time restore to recover subsequent transactions, which can mean significant data loss if the backup is not recent.

What happens if I change the recovery model from Full to Simple and then back to Full?

Changing from Full to Simple breaks the logical chain of log backups. When you switch back to Full, it’s as if a new chain is starting. Log backups performed before the switch to Simple will no longer be usable for a point-in-time restore after returning to Full. To ensure an intact log chain, it is advisable to perform a new full backup immediately after switching to Full.

What is the role of NORECOVERY and RECOVERY in RESTORE statements?

NORECOVERY tells SQL Server not to complete the recovery phase of the database after the restore, leaving it in a RESTORING state. This allows additional backups (differential or log) to be applied in sequence. RECOVERY, on the other hand, completes the recovery process, brings the database online, and makes it accessible to users. RECOVERY is the default option if nothing is specified.

How often should I test my backups?

The frequency of restore tests depends on the RTO (Recovery Time Objective) and RPO (Recovery Point Objective) requirements of your environment. Many organizations choose to test a sample of backups at least once a month, or after any significant change to the database infrastructure or backup strategy. For mission-critical systems, weekly or even daily testing in a staging environment may be justified.

Conclusions with Operational Takeaways

Managing backups and recovery in SQL Server is a critical aspect of any IT infrastructure. It’s not just about performing backups, but about having a clear strategy that considers the recovery model, backup frequency (full, differential, log), compression and checksum options, and especially the ability to restore data in various scenarios. The operational takeaways are:

  1. Define the Recovery Model based on RPO: Choose Full for critical databases requiring point-in-time restore, Simple for those less sensitive to data loss. Your Recovery Point Objective (RPO) is your primary reference.
  2. Always use COMPRESSION and CHECKSUM: These options improve the efficiency and reliability of your backups, reducing space and increasing the likelihood of detecting corruption before it becomes a problem.
  3. Schedule and automate with SQL Server Agent: Backups must be performed regularly and automatically. Configure specific jobs for full, differential, and log backups, and carefully monitor their outcomes.
  4. Test restores regularly: An untested backup is a backup you cannot trust. Perform restore tests on staging environments to verify backup integrity and the validity of recovery procedures. This includes scenarios of restoring to different servers or to a point in time.
  5. Understand log and differential pitfalls: Be aware of recovery model changes that can break the log chain, and the use of copy-only backups that do not reset the differential base. Knowledge of these nuances will help you avoid unpleasant surprises during disaster recovery.

By implementing these practices, you can build a robust and resilient SQL Server data protection strategy, ready to face any failure scenario. Read also: Backup 3-2-1-1-0: Rule Explained with Real Example

Sources

Updated: November 2026

Share this article:

Written by

Rosario Giordano

Rosario Giordano is a system administrator and IT consultant specializing in cybersecurity and cloud, with over 20 years of experience managing enterprise Linux infrastructures. His areas of expertise include SSH hardening, Kubernetes platforms, PostgreSQL databases, VMware/ Proxmox virtualization, and compliance with NIS2 and ISO 27001 security frameworks