SERVER SECURITY GUIDE

VPS Backup Strategy: The 3-2-1 Rule, Immutable Copies and Restore Tests

A backup you have never restored is a hope, not a backup. On a small VPS the usual setup is a nightly job that copies files somewhere, and it fails in predictable ways: the copy lives on the same server, the credentials that write it can also delete it, nobody has tried restoring it, or it has been failing quietly for months. This guide builds a plan that survives disk failure, a mistaken command, a provider incident and an attacker who goes looking for your backups. That last case is not rare: CISA's #StopRansomware Guide warns that "many ransomware variants attempt to find and subsequently delete or encrypt accessible backups to make restoration impossible unless the ransom is paid." The 3-2-1 rule is the starting point, and the sections below add what it leaves out.

Quick win (10 minutes)

  • Write down where your last backup actually is and when it ran. If you cannot answer in one minute, that is the first thing to fix.
  • Check whether that backup lives on the same server or in the same provider account as the VPS. If both, it is a single point of failure.
  • Check whether the server holds credentials that can delete the backup. If it does, an attacker who takes the server can delete it too.
  • Pick one non-critical file and restore it from the backup to a different path. Time how long it takes and note what was missing.
  • Put a reminder in your calendar for a full restore test next quarter.

What to back up and what to skip

Back up what you cannot recreate from a script or a package manager. For most small servers that is:

  • Application data: uploads, user files and anything the app writes at runtime.
  • Databases, as proper dumps rather than copies of live data files. Use pg_dump for PostgreSQL or mysqldump --single-transaction for MySQL so the dump is consistent while the database keeps serving traffic.
  • Configuration: /etc, application configs, systemd units, crontabs, and Docker compose files and volumes.
  • Secrets and keys you cannot regenerate, stored encrypted, plus the backup encryption passphrase itself, kept somewhere that is not the server.

Skip operating system packages, caches and temporary files, which you can reinstall. Logs are optional, but keep a copy of authentication and application logs elsewhere if you want evidence after an incident, as covered in the breach response guide.

The 3-2-1 rule, and what it misses

The rule says to keep three copies of your data, on two different kinds of storage, with one copy off-site. It is generally credited to photographer Peter Krogh, who described it in The DAM Book. The point is to remove single points of failure: a dead disk, a deleted volume or a lost data centre should never take every copy with it.

What the rule does not say is whether an attacker can reach those copies. Some vendors extend it to 3-2-1-1-0: one more copy that is immutable or air-gapped, and zero errors after automated verification. The naming varies by source, but the two additions are the right ones for a server that can be compromised. Follow the rule, then make sure at least one copy cannot be changed or deleted from the production server, and that you verify what you wrote.

Why provider snapshots are not a strategy

VPS snapshots are convenient, fast to take and useful before a risky change. They are a poor primary backup for three reasons. They usually live in the same provider account as the server, so one compromised account, one billing lock or one provider incident can remove the server and its snapshots together. They capture the whole disk, including whatever malware was already on it. And restoring typically means replacing the entire machine, which is a blunt tool when you only need last Tuesday's version of one directory.

Keep snapshots as a convenience, and keep independent file-level backups stored somewhere your VPS account cannot touch.

Encrypted backups with restic or Borg

Two open-source tools do most of what a small server needs: both deduplicate, compress, support retention policies and encrypt data before it leaves the server. According to the restic documentation, a password is required to access the repository, so protect it and store a copy offline, because without it the backups are unreadable. A minimal restic routine looks like this:

export RESTIC_REPOSITORY=sftp:backup@backup-host:/srv/restic/vps1
export RESTIC_PASSWORD_FILE=/root/.restic-pass
restic init
restic backup /etc /var/www /srv/data
restic check

Borg offers an important extra: an append-only mode. The Borg documentation explains that in this mode "Borg will never overwrite or delete committed data," and that it is mainly intended to protect backups if a client machine is compromised. You enable it by restricting the client's key on the backup host:

# ~/.ssh/authorized_keys on the backup host
command="borg serve --append-only --restrict-to-path /srv/backups/vps1",restrict ssh-ed25519 AAAA... vps1-backup

# on the VPS
borg init --encryption=repokey ssh://backup@backup-host/srv/backups/vps1
borg create --stats ssh://backup@backup-host/srv/backups/vps1::{hostname}-{now} /etc /var/www /srv/data

Read the caveats in the docs: append-only only protects the repository's low-level structure, pruning and deleting from a normal session can still permanently remove data, plain rm on the backup host bypasses it, and an attacker could still corrupt a few chunks. The Borg authors recommend running borg check --verify-data before pruning.

Want a second opinion on your current setup?

A free, read-only server check reviews backup freshness, exposed services and patch status without changing anything.

Get your free server check Talk to a security engineer

Make one copy impossible to delete

For at least one copy, take deletion off the table. With object storage this is called Object Lock. In Amazon's words, S3 Object Lock "can help prevent Amazon S3 objects from being deleted or overwritten for a fixed or variable amount of time, or indefinitely," using a write-once-read-many model, and it works only on buckets with versioning enabled. In compliance mode no user, including the account's root user, can delete a protected version during the retention period; governance mode lets specially permitted users override it. Other providers offer similar features under names such as immutable buckets.

CISA gives the same advice in security terms: "enable delete protection or object lock on storage resources often targeted in ransomware attacks." Treat it with some care, though. The same guide cautions that immutable storage "does not meet compliance criteria for certain regulations," and a lock protects only the versions you locked, so set retention long enough to outlast the time it takes you to notice a problem. A pull-based design helps too: have a separate backup host fetch data from the VPS, so the VPS never holds credentials that can erase history. The ransomware protection guide explains why this separation matters.

Test restores, or you have nothing

CISA's advice is to "regularly test the availability and integrity of backups in a disaster recovery scenario." Do two kinds of test. A light one monthly: restore a single file and a database dump to a scratch location and check they open. A full one at least quarterly, and after major changes: build a fresh VPS, restore onto it, start the application and confirm it works.

Use the full test to measure two numbers you should know before an incident. Your recovery point objective is how much recent data you can afford to lose, which sets how often you back up. Your recovery time objective is how long you can be down, which tells you whether your restore process is fast enough. Also run the integrity tools, restic check or borg check --verify-data, so corruption shows up in a drill rather than during an outage. Keep several generations: CISA warns that dropper malware must be identified before restoring, and an older clean copy gives you somewhere to go if the newest one is already infected.

Retention, schedule and monitoring

A reasonable starting point for a small server is a nightly backup, with retention of roughly seven daily, four weekly and six monthly copies, adjusted to how fast your data changes and how long a problem might go unnoticed. Run the job from a systemd timer or cron, and log its output. Most important of all, alert when it fails or does not run: a silent backup job is the commonest cause of discovering at the worst moment that there is nothing to restore. The server monitoring guide shows how to wire that up.

Finally, write the restore procedure down, including where the passphrase is, which host holds the repository and the exact commands. In an incident you will be tired and short of time, and a tested checklist is worth far more than good intentions. It also belongs in your wider hardening plan: see the VPS security checklist.

A recent reminder of why a copy must live outside the provider: the Yandex data center outages of October 2026.

Terms used here: RPO and RTO and Object Lock.

Frequently asked questions

What is the 3-2-1 backup rule?

Keep three copies of your data (the original plus two backups), on two different kinds of storage, with one copy off-site. It is generally credited to Peter Krogh. Some vendors extend it to 3-2-1-1-0 by adding an immutable or air-gapped copy and zero errors after verification.

Are VPS provider snapshots enough as a backup?

No. Snapshots usually live in the same provider account as the server, capture the whole disk including any malware, and are a blunt tool for restoring single files. Use them as a convenience and keep independent, file-level backups stored where your VPS account cannot reach.

How often should I back up a VPS?

As often as the amount of recent data you can afford to lose. Nightly is a common starting point for a small server, with more frequent database dumps if the data changes quickly. Your recovery point objective should decide it, not convenience.

What is an immutable backup?

A copy that cannot be modified or deleted for a set retention period, even by an administrator or an attacker who has stolen your credentials. Examples are S3 Object Lock in compliance mode and Borg repositories used in append-only mode.

How do I test that my backup actually restores?

Restore a few files and a database dump to a scratch location every month, and do a full rebuild on a fresh server at least quarterly. Run restic check or borg check --verify-data as well, and write down how long the restore took.

Do I need to encrypt my backups?

Yes, because copies stored off the server contain all of your data. restic and Borg encrypt before data leaves the server. Keep the passphrase somewhere other than the VPS, because without it the backups cannot be read.

Not sure where your server stands?

Get a free, read-only security check, or talk to a security engineer about managed protection.

Get your free server check Talk to a security engineer