The 3-2-1 Backup Rule for Servers: How to Set Up Offsite Backups Before a Breach

The 3-2-1 Backup Rule for Servers: How to Set Up Offsite Backups Before a Breach

A server without a tested backup is a server with a countdown running. Disks fail, updates break databases, and attackers delete the first thing they find, which is usually the backup sitting on the same machine. The 3-2-1 backup rule is a simple count that fixes the most common failure: keep 3 copies of your data, on 2 different media types, with 1 copy offsite. This guide turns that count into a working setup for a VPS, and shows how to test it before you need it.

The three numbers each guard against a different failure. Three copies guard against a bad backup, because one copy can be corrupt without you knowing. Two media types guard against a failure mode that takes out one whole class of storage, such as a disk array dying. One offsite copy guards against the failure that takes the whole server, from a datacenter outage to ransomware that encrypts everything it can reach. Skip any one number and a single event can still take all your copies at once.

The 3-2-1 Backup Rule Applied to a VPS

On a VPS, the live data is copy one. A local backup on the same server, such as a nightly archive in /backup, is copy two, but it shares the fate of the server, so it does not count as the offsite copy. The offsite copy is the one that matters most, and it should live with a different provider or in a different region, reachable only with credentials that are not stored on the server itself in plain text.

A practical VPS layout looks like this. The live site and database run on the VPS. A nightly job writes a compressed archive and a database dump to local disk. A second job copies those files to object storage, such as an S3-compatible bucket, and deletes local archives older than a few days to save disk. The bucket holds versioned copies, so an overwritten or deleted file can still be recovered from an earlier version.

tar -czf /backup/site-2026-10-31.tar.gz /var/www/example.com
mysqldump -u root exampledb > /backup/db-2026-10-31.sql
rclone copy /backup remote:example-backups --progress

The offsite backup copy is the one to protect hardest. Give the storage credentials read and write access to one bucket only, never to the whole storage account. Turn on versioning or object lock on the bucket if the provider offers it, so a compromised server cannot delete the backups it can reach. An attacker who can wipe your backups has removed your recovery option, which is exactly why the offsite copy needs separate credentials and delete protection. Our comparison of Backblaze B2, Hetzner Storage Box, and Wasabi covers providers that work well as that offsite target.

What to Back Up: Files, Databases, and Config

Most failed restores trace back to an incomplete backup set. A site backup needs three parts: the web files, the database, and the server config that makes the site run. Files without the database give you an empty shell. A database without the files gives you content with no code. Both without the Nginx config, PHP settings, and cron jobs give you a long rebuild on a bad day.

Back up the web root, the database dump, and a config directory that holds copies of your Nginx vhosts, PHP-FPM pools, firewall rules, and cron tables. Keep the list in a script so the same set runs every night, and keep the script itself in version control or in the backup set. A backup job that depends on a human remembering each path will eventually miss one.

sudo crontab -l > /backup/cron-root.txt
sudo cp -r /etc/nginx/sites-available /backup/nginx-sites/
sudo ufw status numbered > /backup/ufw-rules.txt

WordPress owners have one extra item: the uploads directory and the wp-config.php file, since uploads are the only content that never lives in the database. Our guide on backing up Docker volumes automatically covers the same problem for container setups, where the data lives in volumes rather than plain directories. The principle is identical: back up the data, not just the container image, because the image can be rebuilt and the data cannot.

Schedule, Retention, and the Restore Test

A backup that never runs on schedule is a hope, not a backup. Run the job nightly with cron, log its output, and alert on failure. A job that fails silently for a month leaves you with a month-old restore point on the day you need a fresh one. Check the log weekly, and set the job to send a message on failure through a monitoring tool or a simple mail alert.

0 3 * * * /usr/local/bin/backup-server.sh >> /var/log/backup.log 2>&1

Retention is the second half of the schedule. Write the server backup schedule and the backup retention policy down in one document, so the next admin can see what runs nightly and how long each copy is kept. Keep daily copies for a week, weekly copies for a month, and monthly copies for a few months. This ladder matters because some damage is discovered late: a corrupted database or a hacked site found two weeks after the event needs a clean copy from before the event, not last night’s copy of the already damaged data. Storage is cheap compared with a restore point that is too new to help.

The restore test is the step that separates a backup plan from a backup fantasy. Every month, restore to a spare directory or a cheap test VPS and confirm the site loads and the database opens. A restore test finds the missing pieces, such as a config file nobody backed up or an archive that is corrupt, while there is still time to fix the job. Our comparison of Duplicati, Restic, and Kopia for Docker volumes is useful reading here too, since each tool’s restore command differs and the test should use the exact commands you would run in an emergency.

Limits of the Rule and What It Does Not Cover

The rule is a floor, not a complete plan. It says nothing about encryption, so encrypt backups that hold personal data before they leave the server, and store the encryption key somewhere other than the server. It says nothing about restore speed, so a huge archive on slow storage may take hours to download when the site is already down. Test the download time, not just the backup time.

It also does not cover the case where the backup itself is the attack path. A backup job running as root with credentials to the whole storage account can be abused to delete or encrypt every copy. Scope the credentials, turn on versioning, and keep one copy that the server cannot delete, even if that copy is only updated weekly. A weekly immutable copy beats a nightly deletable copy on the day an attacker gets root.

For a look at paid tooling that automates much of this, see our roundup of the best paid backup tools for Docker volumes in 2026. The tool matters less than the routine: three copies, two media, one offsite, a schedule that runs, and a restore you have actually performed. Set that up this week, while the server is healthy, because the week you need it is the worst week to build it.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.