Ransomware-Resistant Linux Backup System with Immutable Storage — Practical Guide

Overview

Traditional backups often fail during ransomware attacks because attackers can delete, encrypt, or modify backup data.
A ransomware-resistant backup system must ensure that even root cannot alter backup files once written.

This guide explains how to build an immutable backup architecture on Linux using:

This approach is widely used in enterprises but rarely documented in a single, practical guide.


Threat Model

This design protects against:


Supported Linux Distributions


Architecture Overview

Production Server
   |
   | (rsync / ssh)
   v
Backup Server
   ├── Immutable Backup Directory
   ├── Append-only files
   ├── Snapshot layer
   └── Offline retention

Step 1: Prepare Dedicated Backup Server

Create backup user:

useradd -m -s /sbin/nologin backupuser
passwd backupuser

Create backup directory:

mkdir -p /backups/servers
chown backupuser:backupuser /backups/servers
chmod 750 /backups/servers

Step 2: Enable Append-Only Attribute

Apply append-only flag:

chattr +a /backups/servers

Verify:

lsattr /backups

What This Does


Step 3: Harden Backup Permissions

Restrict root access:

chmod 700 /backups/servers

Prevent accidental writes:

setfacl -m u:backupuser:rwx /backups/servers

Step 4: Snapshot the Backup Volume

If backups are on LVM:

lvcreate -L 10G -s -n backup_snap /dev/vg0/backups

Mount snapshot:

mount -o ro /dev/vg0/backup_snap /mnt/backup_snap

This provides secondary protection against data loss.


Step 5: Configure Secure Backup Transfer

From production server:

rsync -aAXHv \
--numeric-ids \
--link-dest=/backups/servers/previous \
/data/ backupuser@backup-server:/backups/servers/current

Hard links reduce space usage and preserve history.


Step 6: Lock Backup After Completion

Once backup completes:

chattr +i /backups/servers/current

Immutable Flag Effects


Step 7: Rotation Strategy (Safe Window)

During scheduled rotation:

chattr -i /backups/servers/current
mv /backups/servers/current /backups/servers/2026-01-28
chattr +i /backups/servers/2026-01-28

Only the backup automation window has write access.


Step 8: Off-Site Replication (Optional)

Replicate immutable backups:

rsync -a --numeric-ids /backups/servers remote-backup:/vault/servers

Use pull-only model from remote side.


Step 9: Verification & Audit

Verify immutability:

rm -rf /backups/servers/current

Expected result:

Operation not permitted

Check attributes:

lsattr /backups/servers/current

Step 10: Restore Procedure

Temporarily unlock:

chattr -i /backups/servers/2026-01-28

Restore:

rsync -aAXHv /backups/servers/2026-01-28/ /restore/

Re-lock immediately after restore.


Best Practices


Common Mistakes


Enterprise Use Cases


Conclusion

By combining append-only storage, immutable attributes, and snapshots, Linux administrators can create a ransomware-resistant backup system that remains safe even during full system compromise.

This architecture is enterprise-proven but rarely documented in a complete, practical manner.