How to Secure Database Backup Files from Ransomware Attacks

Ransomware attackers hit backups first, and most teams hand them over without realizing it. Learn why immutability is the one control that survives a compromised admin account—and why an untested backup is just a hypothesis.

How to Secure Database Backup Files from Ransomware Attacks

Your database backups are the single most valuable target on your network, and most teams have them configured in a way that hands them over voluntarily. Here's the pattern I keep seeing: a company gets hit, the ransom note arrives, and the first thing the IT lead says is "we have backups." Then they go look. The backup share is encrypted too. The backup service account had domain admin. The repository was mounted read-write on the same host as the production SQL Server.

I've walked through this exact scenario with four different teams over the past few years, and in three of them the backups were compromised in the same attack. Not because the attackers were brilliant, but because the backup infrastructure inherited every weakness of the environment it lived in. Securing database backup files from ransomware is a different problem than securing ordinary file shares, because databases have their own attack surface: service accounts with broad privileges, WAL and transaction log streams that must be written to, and restore procedures that nobody tests until they need them.

Key Takeaways

  • Attackers target backup repositories first because deleting them removes your recovery option entirely
  • Immutability (WORM storage or object lock) is the single control that survives a compromised admin account
  • Database-specific concerns matter: lock down the backup service account, separate it from production credentials, and watch transaction log shipping
  • A backup you have never restored is a hypothesis, not a backup
  • The 3-2-1 rule needs a fourth number in 2026: at least one copy that cannot be deleted or modified

How to secure database backup files from ransomware: start with the assumption you're already breached

Most guidance on this topic opens with "ransomware operators now target backups." True, but it leads people to add a firewall rule and call it done. The useful mental model is different: assume an attacker already has credentials inside your environment, and design your backup architecture so that even with those credentials, they cannot destroy your ability to restore.

That assumption changes what "secure" means. A password-protected backup file is worthless against someone who has the password. A backup on a network share is worthless if the share is mounted on a machine the attacker controls. Security here comes from separation and immutability, not from secrecy.

Why database backups are a different problem

File-level backups are relatively simple to isolate. Database backups are not, and here's why: the mechanism that produces them has to run continuously. SQL Server Agent jobs, PostgreSQL's pg_basebackup and WAL archiving, MySQL's binary log shipping, Oracle RMAN—all of these need a persistent credential with write access to a repository. That credential becomes the pivot point.

A mistake I made early on: I configured the backup service account with sysadmin on the instance because it was the path of least resistance. Six months later, during a security review, I realized that account could also read every table in the database. It was a backup account that functioned as a full data-access account. That's not a backup account. That's a liability.

The fix took me two weeks of careful work: a dedicated login with exactly BACKUP DATABASE and BACKUP LOG rights, nothing else, plus a second separate credential for the storage target. It broke two scheduled jobs on the first attempt and I spent a Friday night fixing them. Worth it.

  • Create a dedicated backup principal with only the permissions required to back up and nothing that allows reading data
  • Separate the database credential from the storage credential—one writes the file, the other places it
  • Rotate the storage credential on a schedule, and log every rotation
  • Never let the backup service account authenticate to the domain with interactive logon rights

How to protect backup data from ransomware

Protection means making it impossible for a compromised account to do three things: delete the backups, encrypt them in place, and modify them silently. Each of those needs a different control.

How to protect backup data from ransomware

Immutability is the control that actually works

Object storage with WORM capability (S3 Object Lock in compliance mode, Azure immutable blob storage with a legal hold, or equivalent on-premises tape) means that for a set retention window, the object cannot be deleted or overwritten—even by an account with full administrative rights. That's the crucial property. Not "the attacker doesn't have permission," but "the storage layer refuses the operation."

Configuration details that matter and that most guides skip:

  • Set retention at the storage bucket level and verify the setting with a test delete—if the delete succeeds, the lock isn't active
  • Enable MFA-delete so removing the lock requires a second factor from a separate device
  • Choose a retention window longer than your realistic detection time. If it takes you eight days to notice a compromise, a seven-day lock is decorative
  • Keep the lock configuration managed by a different account than the one that writes backups

Honestly, this is the single most effective thing on the list. If you do nothing else, do this.

Network separation and the air gap

Immutability protects the data at rest. Network separation protects the path to it. A backup repository should not be reachable from the production subnet on a general-purpose protocol. If your database server can mount the backup share as a drive letter, so can anything that lands on it.

A pattern that works well, and that I've deployed twice now: the backup agent pushes to a staging host in a dedicated VLAN, which then pushes to the repository over a one-way rule. No reverse path. No SMB from production to the repository. The staging host has no domain membership and no inbound access from anything except the database host on a single port.

For the most sensitive data, an offline copy—tape ejected and stored, or a removable drive rotated on a schedule—still has a place. It's inconvenient. That's the point.

Which type of backup is most secure against ransomware?

There isn't one winner; the answer depends on what you're protecting and how much time you have. But there's a meaningful ranking, and it has less to do with the format than with what surrounds it.

Which type of backup is most secure against ransomware?
Backup type Exposure to a compromised host Restore speed Practical notes
Logical dump (pg_dump, mysqldump, SQL export) Moderate—the file lands on a filesystem the host can usually reach Slow to very slow for large datasets Easy to encrypt, easy to copy; poor fit for very large databases
Physical snapshot / base backup Depends entirely on where it's stored Fast Captures the whole instance; needs consistent storage-level coordination
Continuous log shipping (WAL, binlogs) High—the stream must be written continuously Fast to a point in time Essential for RPO under an hour; also the easiest stream to disrupt
Immutable object storage copy Low—storage layer refuses modification Moderate; retrieval cost varies Best combination of availability and tamper resistance
Offline / air-gapped media Very low Slow; requires physical access Last-resort tier; the one nobody can reach remotely

If you're choosing a single approach and can only do one thing, choose immutable object storage with a retention lock. It's the only option that survives an attacker holding administrative credentials. Everything else is a supporting layer.

What is the 3/2/1 rule for ransomware?

The 3-2-1 rule says: keep three copies of your data, on two different media types, with one copy offsite. It's been around since the era of tape rotations, and it's still a reasonable baseline. It's also no longer sufficient on its own.

The extended version you'll hear called 3-2-1-1-0 adds two clauses that matter for ransomware: one copy that is immutable or offline, and zero errors—meaning you have verified the backups actually restore. That last part is where most organizations fail.

I audited a mid-sized company's backup setup a while back and found backups ran successfully every night for eleven months. Every job green in the console. Then we tried a restore. The database dump had been silently truncated for at least four of those months, and the integrity check hadn't been run because it was disabled by default. Eleven months of green checkmarks, four months of useless backups. Nobody knew.

Verification is a job, not a checkbox. What I recommend now:

  • Automate a restore of the most recent backup into an isolated environment on a fixed cadence—weekly for critical databases
  • On every restore test, run a row count comparison and a checksum against the source where feasible
  • Scan restored files with an offline scanner before mounting them anywhere production-adjacent
  • Record restore duration, not just success. RTO claims are meaningless without measured numbers

What is the safest way to back up my data?

The safest method combines three properties: the backup is written to a system that cannot be modified after writing, that system is not reachable from the systems that hold your production data, and you have proven the restore works on a schedule you can defend.

For a database specifically, the practical stack looks like this. Continuous log shipping for point-in-time recovery within a short window. A nightly full or incremental backup to staging. A push from staging to immutable storage with a retention lock of at least thirty days. One periodic offline copy stored physically. And a restore test living in your incident procedures file, not in somebody's memory.

The credential surface is where it breaks

In every incident review I've done, the failure wasn't the backup technology. It was a credential. A backup service account with domain admin. An API key committed to a script in a public repository. A storage access key shared across four teams and never rotated. Attackers know this—they scan for it specifically.

Practical hardening:

  • Rotate every backup-related credential on a defined schedule, not when it's convenient
  • Use short-lived tokens where your cloud supports it, rather than long-lived keys
  • Log all backup job changes to an append-only destination. If a job's schedule or target is modified, you want that in a record nobody can edit
  • Alert on job failures, on unexpected deletions, and on executions outside normal windows. An attacker deleting backups will trip at least one of these

A monitoring gap that caught me out once: I had alerting on job failures but not on job deletions. An attacker—or, as it turned out, a careless contractor—could delete a backup job entirely and the monitoring stayed silent. Now I alert on any modification to the backup job inventory, and I sleep better.

The uncomfortable truth is that most organizations don't lose data because their backup solution was weak. They lose it because the backup solution was convenient, and convenience means reachable, and reachable means the attacker got there too. The work of securing database backups from ransomware is mostly the work of making them inconvenient to reach—and proving, on a schedule, that you can still get the data back when it matters.

Wendy Vaughan

Wendy Vaughan

Wendy Vaughan is a cloud architect and DevOps strategist with deep expertise in distributed systems. She helps engineering teams design resilient, scalable platforms and streamline their delivery pipelines. Her practical approach blends technical rigor with a clear focus on real-world outcomes.

See all articles →

Related articles