Backup All transaction logs
Job details
Name: |
Backup All transaction logs |
Platform: |
Sqlserver |
Category: |
Maintenance |
Premium package: |
Maintenance package |
Description: |
Takes backup of all transaction logs for databases running in FULL recovery mode. |
Long description: |
Takes backup of all transaction logs for databases running in FULL recovery mode. |
Version: |
2 |
Default schedule: |
0 * * * |
Requires engine install: |
Yes |
Compatibility tag: |
.[type=‘instance’ & databasetype=‘sqlserver’]/instance[maj_version > ‘2000′ & hasengine=‘YES’]/.[engine_edition = ‘Microsoft SQL Server’ & eng_inst_priv = 0] |
Parameters
Name |
Default value |
Description |
backup directory |
|
Directory path for backup files. Exp. D:\Backup_db\ |
delete old backup files (in hours) |
48 |
The task deletes backup files older than the parameter value (in hours). |
ignore databases |
|
List over the database (separated by comma) which will be ignored from being backuped. |
enable |
NO |
If set to “YES“ the task will run “backup database” command for every online database. This task is meant for Desktop editions of SQL Server where SQL Agent service is not running. Default value is “NO”. |
backup device |
null |
Name of the backup device. If this parameter is configured (set to value “null”), the “backup directory” and “delete old backup files (in hours)” parameters will be ignored. Only DISK type devices are supported. |
compress backup |
YES |
If set to “YES“ the “WITH COMPRESSION“ option will be added to “BACKUP LOG“ DDL command. COMPRESSION is not supported on Express Edition and MS SQL Server 2005. |
create subdir |
YES |
Creates the sub directory (if it does not exist) for each database that is backed up. The xp_create_subdir procedure is used. |
Job Summary
- Purpose: The purpose of this job is to manage the backup of transaction logs for databases in a SQL Server environment, specifically focusing on those running in FULL recovery mode.
- Why: This job is crucial for ensuring data integrity and enabling the possibility to restore data to any point in time. Without transaction log backups, only full or differential backups would be available, limiting the restore points and potentially increasing data loss during a disaster recovery.
- Manual checking: You can check transaction log backups manually in the database using the below SQL commands:
SELECT database_name, backup_finish_date, backup_size FROM msdb..backupset WHERE type = 'L' ORDER BY backup_finish_date DESC
Implementation
- This job involves various database operations, including:
- Creation of necessary tables and procedures for managing backup operations and error handling.
- Execution of backup operations for each online database adhering to certain properties, as defined in the long description in the XML content. Conditions like database status being online, access level being multi-user, and not being a publication or subscription participant are checked.
- Handling of ignore lists for databases and compression of backups based on conditions and SQL Server edition.
Dependencies and Cleanup
- There are several critical dependencies for execution:
- dbw_backup_transaction_log_proc (Main procedure for performing backups)
- dbw_backup_transaction_log_err_tab (Error table to record any issues during the backup process)
- dbw_backup_transaction_log_histr (Table to maintain historical logs about backup executions)
- Cleanup on failure ensures that the system remains clean even if the job fails, which helps prevent clutter and potential data confusion in management tables.
Parameters and Configuration
- Some of the parameters the job uses include:
- Backup directory
- Whether to delete old backup files (and the age after which files are deleted)
- Databases to ignore
- Whether backups should be enabled
- Specification of the backup device
- Compression setting
- Whether to create subdirectories per database
Reporting and Monitoring
- Transaction log backups are tracked and reported, providing essential metrics such as:
- Count of databases backed up
- Errors encountered during backups
- Backup sizes
- Start and end times of backups
- The elapsed time for backups
Reporting Examples
Database Name |
Backup Start |
Backup Finish |
Size (MB) |
Database1 |
10 AM |
10:05 AM |
50 MB |
Database2 |
11 AM |
11:06 AM |
45 MB |
- The report also includes execution history for backups and lists any databases that encountered errors during backup.
I hope this summary provides a comprehensive understanding of the job’s functionality and its critical role within the database management environment.