3041

Fix SQL Server Backup Compression Failure with Error 3041

When backing up a SQL Server database with compression, the job fails with error 3041. The fix is usually a missing trace flag or a disk space issue. Here's what to check.

When does this error happen?

You're running a backup job — maybe from a maintenance plan, maybe from a T-SQL command — and you turned on compression with MAXTRANSFERSIZE or COMPRESSION option. The job fails with error 3041: "BACKUP failed to complete the command". The backup file might be 0 bytes or missing. This happens a lot on SQL Server 2016 through 2022, especially when you're backing up to a network drive or using a third-party backup tool that pushes compression.

What's actually happening here?

SQL Server tries to compress the backup stream. But behind the scenes, the compression engine needs enough contiguous memory and I/O bandwidth. The error 3041 is a catch-all: it means the backup operation couldn't finish for some reason. The two biggest triggers are:

  • Disk space — The backup file grows slower with compression, but if the target location runs out of space mid-way, SQL Server cancels the whole backup. It won't finish writing. The error code is 3041, not a disk full error.
  • Trace flag 3041 — In some builds, SQL Server doesn't report compression failures clearly. You need trace flag 3041 enabled to see the actual reason in the log. Without it, you just get the generic 3041 error.

What about the backup to URL scenario?

If you're backing up to Azure Blob or S3-compatible storage, the error often shows up because the backup file size exceeds the 1 TB limit for a single backup file on certain storage backends. Or the network timeout is too short for a large compressed backup. But that's a different category — here we're talking about local or network disk backups.

The fix — step by step

  1. Check disk space on the target drive
    Run EXEC xp_fixeddrives or check with PowerShell. You need at least 1.5x the size of the final compressed backup. For a 50 GB database, that's around 75 GB free. SQL Server writes a temporary file during compression, so it needs room to expand before contracting. If you see less than that, free up space or change the target.
  2. Enable trace flag 3041 globally
    This makes SQL Server log the real reason for the failure. Run this:
    DBCC TRACEON(3041, -1);
    GO
    -- Confirm
    DBCC TRACESTATUS();
    Then retry the backup. Check the SQL Server error log for a more detailed message. It might say something like "Insufficient disk space" or "Compression failure: I/O error".
  3. Check MAXTRANSFERSIZE and BUFFERCOUNT
    If you're using MAXTRANSFERSIZE = 65536 (the default for compression), some older Windows Server builds have issues with large I/Os. Set it explicitly to MAXTRANSFERSIZE = 1048576 (1 MB) and BUFFERCOUNT = 32. Example:
    BACKUP DATABASE MyDB
    TO DISK = 'D:\Backups\MyDB.bak'
    WITH COMPRESSION,
    MAXTRANSFERSIZE = 1048576,
    BUFFERCOUNT = 32;
    This gives SQL Server smaller I/O chunks, which reduces memory pressure.
  4. Disable third-party backup tools temporarily
    Tools like Redgate or Idera often intercept the backup command. They can break compression handling. Try running the backup from a simple BACKUP DATABASE command in SSMS. If it works, the issue is the third-party tool. Update it or change its compression settings.
  5. Verify the SQL Server version and patch level
    Run SELECT @@VERSION. Microsoft fixed several compression bugs in cumulative updates for SQL Server 2017 and 2019. If you're on an older CU, apply the latest one. For example, SQL Server 2019 CU14 had a fix for backup compression failures on large databases. Without the patch, you get error 3041 randomly.

What to check if it still fails

  • Check the Windows System Event Log — Look for disk errors, like Event ID 11 (controller error) or 153 (disk timeout). The drive might be failing. Replace the drive.
  • Test with compression off
    Run BACKUP DATABASE MyDB TO DISK = '...' WITH NO_COMPRESSION;. If it succeeds, the issue is compression-specific. Then try the WITH COMPRESSION (ALGORITHM = MS_EXPRESS) option (available in SQL Server 2022). It uses less memory.
  • Check user permissions — The SQL Server service account needs ALTER ANY DATABASE and CREATE BACKUP DEVICE. Also write permission on the target folder. Deny write access gives you 3041 too.
  • Look at the SQL Server error log timestamp — If the error happens at the same time every day, something else is running (like a full backup or a large query) that starves memory. Schedule the backup at a different time.

If you've done all this and it still fails, you might have a corrupted database file. Run DBCC CHECKDB to check. A corrupted database can cause backup compression to abort. Fix the corruption first, then try again.

Related Errors in Database Errors
0X00000559 Fix ERROR_RXACT_INVALID_STATE (0x00000559) in Registry Transactions Database View Definition Lost After Restore – Fix It Fast InnoDB: Error: Crash recovery failed MySQL InnoDB Crash Recovery Stuck – Real Fixes That Work 0XC0190023 SQL Server Error 0xC0190023: Miniversion Invalidated Fix

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.