Skip to content
Wallet live · USDT TRC20 · USDT BEP20 · BTC · ETH · SOL · XMR Free SSL · Malware scan · Instant image 24/7 desk · @rexahost
RexaHostRexaHost

Guides

VPS Backup Strategy: Applying the 3-2-1 Rule to Your Server

· 6 min read

VPS Backup Strategy: Applying the 3-2-1 Rule to Your Server

Snapshots alone are not a backup plan. How to apply the 3-2-1 rule to a VPS with automated, encrypted, off-site backups and regular restore tests.

Key takeaways

  • 3-2-1: three copies, two kinds of storage, one off-site.
  • Back up data and configuration, not the whole OS, so restores are fast and clean.
  • Dump databases properly before backing up; copying live database files can produce corrupt backups.
  • Encrypt off-site backups and automate them with a scheduler.
  • A backup you have never restored is a hope, not a plan. Test restores regularly.

On a VPS you have full control, which also means backups are your responsibility. Hardware fails, people delete the wrong directory, updates break things, and compromised servers sometimes need to be rebuilt from scratch. A solid backup strategy turns each of these from a disaster into an inconvenience. The time-tested framework for that strategy is the 3-2-1 rule.

The 3-2-1 rule explained

  • 3 copies of your data: the live copy plus two backups.
  • 2 different storage types or systems, so a single fault cannot destroy every copy.
  • 1 copy off-site, in a different location or with a different provider.

Some teams extend this to 3-2-1-1-0: one copy offline or immutable (cannot be changed or deleted, protecting against ransomware), and zero errors when restores are verified.

What can go wrong (and what protects you)

RiskSnapshot on same platformOff-site backup
Accidental file deletionYesYes
Bad update or config changeYesYes
Compromised serverPartly (if snapshot predates attack)Yes
Attacker or mistake deletes backupsNo, if same credentialsYes, if append-only or separate keys
Account or billing problemNoYes
Data centre incidentNoYes

Step 1: Decide what to back up

Rather than imaging the whole disk, back up what you cannot easily recreate:

  • Application data: website files, uploads, user content.
  • Databases: as proper dumps (see below).
  • Configuration: /etc (especially web server, PHP, firewall and cron), Docker Compose files, environment files.
  • Secrets: certificates and keys, stored encrypted.
  • Documentation: a short README of how the server was built.

The OS itself can be reinstalled in minutes. Better still, script your setup so rebuilding is repeatable.

Step 2: Set your recovery goals

  • RPO (Recovery Point Objective): how much data you can afford to lose. A blog might accept a day; a shop might accept only an hour.
  • RTO (Recovery Time Objective): how quickly you need to be back online.

Your RPO sets backup frequency. Your RTO determines whether you need a warm standby server or whether restoring onto a fresh VPS is fast enough.

Step 3: Back up databases correctly

Copying database files while the database runs can produce an inconsistent backup. Use the database's dump tools instead:

# MySQL / MariaDB (InnoDB)
mysqldump --single-transaction --routines --all-databases | gzip > /backup/db-$(date +%F).sql.gz

# PostgreSQL
pg_dumpall | gzip > /backup/pg-$(date +%F).sql.gz

Run the dump just before your file backup so both are captured together.

Step 4: Choose a backup tool

ToolStrengthsNotes
resticEncrypted, deduplicated, many storage backendsGreat default for most VPS users
BorgBackupEncrypted, deduplicated, fastWorks best with an SSH target
rsyncSimple, ubiquitousNo built-in encryption or versioning; combine with snapshots
Panel backups (cPanel etc.)Easy, complete account backupSend copies off-site

Step 5: Example with restic

# Install
sudo apt install restic

# Set the repository and password (store these safely)
export RESTIC_REPOSITORY=sftp:backup@backup-host:/srv/restic/web1
export RESTIC_PASSWORD_FILE=/root/.restic-pass

# Initialise once
restic init

# Back up
restic backup /var/www /etc /backup

# Apply retention
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune

Schedule the dump and restic commands in a script run nightly by cron or a systemd timer. Send yourself an alert if the job fails.

Step 6: Put one copy off-site

Options for the off-site copy:

  • A second VPS in another location used as a backup target. A small plan with enough disk works well; VPS Basic gives you 60 GB of NVMe for $5.98 a month, and VPS Pro 120 GB for $11.58.
  • Object storage from a separate provider.
  • Your own hardware, such as a NAS at the office, pulling backups over SSH.

Choose a different location from your main server. If your server is in Frankfurt, keep backups in Amsterdam or London, for example. See our guide to choosing a server location.

Step 7: Protect the backups themselves

  • Encrypt everything that leaves the server. restic and Borg do this by default.
  • Use pull or append-only access so a compromised web server cannot delete its own backups. A backup server that pulls data, or an append-only repository, prevents this.
  • Store the encryption password separately, for example in a password manager. Without it, encrypted backups cannot be restored.
  • Limit access with dedicated SSH keys restricted to backup commands.

Step 8: Test restores

  1. Monthly, restore a recent backup to a test directory or a temporary VPS.
  2. Import the database dump and start the application.
  3. Confirm the site works and data is current.
  4. Time the process; that is your realistic RTO.
  5. Write down the steps so anyone on your team can repeat them under pressure.

A sample backup plan

CopyWhereFrequencyRetention
1. Live dataProduction VPS--
2. Local dumps/backup on production VPSNightly3 days
3. Off-site encryptedBackup VPS in another cityNightly (hourly DB for shops)7 daily, 4 weekly, 6 monthly

Worked example: a WooCommerce shop

Consider a small online shop on a VPS that takes orders throughout the day. Losing a full day of orders would mean lost revenue, unhappy customers and manual reconciliation with the payment processor, so a daily backup is not enough.

  • RPO: one hour. The database is dumped every hour and shipped off-site with restic, which deduplicates so hourly runs stay small.
  • Files: product images and theme files change rarely, so they are backed up nightly.
  • RTO: two hours. The owner has a written runbook: create a new VPS, install the stack with a script, restore files and the latest dump, then switch DNS.
  • Testing: on the first Monday of each month, the latest backup is restored to a temporary VPS, checked and then deleted. The cost of that test server for a few hours is tiny compared with the confidence it provides.

A personal blog, by contrast, might be perfectly well served by nightly backups, 30 days of retention and a quarterly restore test. Match the plan to what losing data would actually cost you.

Automating and monitoring the job

Backups fail silently more often than they fail loudly. A full disk, an expired SSH key or a changed password can stop backups for weeks before anyone notices. Protect against this in three ways:

  1. Exit codes: make your script stop and report an error if any step fails, using set -euo pipefail in bash.
  2. Heartbeat monitoring: have the script ping a monitoring URL on success. If the ping does not arrive on schedule, the monitor alerts you.
  3. Size checks: a backup that is suddenly much smaller than usual may be missing data. restic's stats command helps you spot this.

Shared hosting users

RexaHost shared hosting plans include daily backups, which covers many accidents. For important sites, download a full cPanel backup periodically, or store it with a separate provider, to meet the off-site part of the 3-2-1 rule.

Common backup mistakes

  • Backups stored only on the same server.
  • Never testing a restore.
  • Forgetting databases or copying live database files.
  • Losing the encryption password.
  • No alerts when backup jobs fail silently.
  • Backup server reachable with the same credentials as production.

Backups as part of incident response

Backups are your safety net when something goes wrong, from a failed upgrade to a security incident. After a compromise, restore onto a fresh server from a backup taken before the intrusion, rather than cleaning the infected system. Our DDoS response runbook covers another type of incident worth planning for.

Need a primary server or a backup target? Browse Linux VPS plans across ten Standard locations, pay with crypto and deploy in minutes.

Frequently asked questions

What is the 3-2-1 backup rule?

Keep at least three copies of your data, on two different types of storage or systems, with one copy off-site, away from the primary server.

Is a snapshot a backup?

A snapshot is useful for quick rollbacks, but if it lives on the same platform as the server it does not protect against every failure. Keep independent off-site copies too.

How often should I back up my VPS?

It depends on how much data you can afford to lose. Daily is a common minimum; busy databases and shops often need hourly backups or continuous replication.

How long should I keep backups?

A typical policy keeps 7 daily, 4 weekly and several monthly backups, balancing recovery options against storage cost.

How do I know my backups work?

Test restores regularly to a separate server or directory and confirm the application runs with the restored data.

#vps backup#3-2-1 backup#restic#database backup#disaster recovery

Plans in this article

Servers mentioned here

VPS Basic

Standard
$2.79 /mo
$5.38Save 48% billed monthly
  • 1 vCPU
  • 2 GB RAM
  • 60 GB NVMe
  • 3 TB traffic
  • Root access · dedicated IPv4
  • Ashburn · London · Amsterdam · Frankfurt +6
Most popular

VPS Pro

Standard
$4.69 /mo
$10.42Save 55% billed monthly
  • 2 vCPU
  • 4 GB RAM
  • 120 GB NVMe
  • 5 TB traffic
  • Root access · dedicated IPv4
  • Ashburn · London · Amsterdam · Frankfurt +6

VPS Business

Standard
$8.39 /mo
$19.06Save 56% billed monthly
  • 4 vCPU
  • 8 GB RAM
  • 240 GB NVMe
  • 7 TB traffic
  • Root access · dedicated IPv4
  • Ashburn · London · Amsterdam · Frankfurt +6

Keep reading

Related articles

Live Chat · offline