Back to articles
DevOps & Systems

3-2-1 Strategy for Comprehensive Data Protection on VPS

A detailed guide on implementing the 3-2-1 backup and disaster recovery strategy for VPS, including configuration, testing, and automation to ensure effective data protection.

DPTCloud Engineering4 min read
3-2-1 Strategy for Comprehensive Data Protection on VPS

3-2-1 Strategy: Comprehensive Data Protection for VPS

In VPS (Virtual Private Server) environments, data loss due to hardware failure, human error, or cyberattacks can cause severe damage. The 3-2-1 strategy is a widely adopted method in DevOps to ensure data availability and system resilience. This strategy includes:

  • 3 data copies: The original data and at least two backup copies.
  • 2 different storage media: Data stored on at least two different types of devices (e.g., SSD, HDD, cloud storage).
  • 1 copy offsite: At least one backup copy stored outside the physical location (e.g., cloud, backup site).

Implementing the 3-2-1 Strategy on VPS

To apply the 3-2-1 strategy on a VPS, you need to combine backup tools, distributed storage, and automated testing. Below is a detailed guide.

1. Configure Periodic Backups with rsync and cron

rsync is an efficient backup tool that supports fast, incremental backups by transferring only changed data. Combine it with cron for scheduled backups.

# Example: Backup /var/www directory to a local backup folder
rsync -avz /var/www/ /backup/www/ --exclude='node_modules/'

# Configure cron to run daily backups
0 2 * * * rsync -avz /var/www/ /backup/www/ --exclude='node_modules/'

2. Store Backups to Cloud or Backup Server

To ensure an offsite copy, use cloud storage services like AWS S3, Google Cloud Storage, or a backup VPS.

# Use rclone to back up to Google Cloud Storage
rclone copy /backup/www/ remote:backup-vps-321 --progress

3. Test and Automate Data Recovery

Regularly testing backups is crucial to ensure they can be restored. Use a simple script to verify backup integrity.

# Check if backup exists and is not corrupted
#!/bin/bash
BACKUP_DIR="/backup/www"
if [ -d "$BACKUP_DIR" ]; then
  echo "Backup exists. Checking contents..."
  ls -la "$BACKUP_DIR"
else
  echo "Backup does not exist! Check again."
fi

3-2-1 Strategy Checklist

Factor Completed Notes
3 data copies ✓ Original + 2 backups
2 storage media ✓ Local + Cloud
1 offsite copy ✓ Stored on cloud or backup VPS
Regular recovery testing ✗ Recovery tests not yet performed

Prerequisites and Notes

  • Prerequisites: Root access to VPS, rsync, rclone, cron, and a cloud storage account.
  • Backup timing: Run backups during low-traffic periods (e.g., 2 AM).
  • Storage analysis: Monitor backup size to avoid running out of disk space.

Verification and Troubleshooting

To verify that backups are working:

# Check rclone status
rclone lsd remote:

# Check backup size
du -sh /backup/www/

If backups fail, check:

  • Storage account access permissions.
  • Network connectivity and backup timing.
  • Backup logs: cat /var/log/cron.

References

DPTCloud Tier III Infrastructure

Recommended NVMe Cloud VPS Plans to Deploy This Setup

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02

VPS-2E

94.600 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 2 GB
  • SSD: 30 GB NVMe
ECO · vn-02Recommended

VPS-3E

170.500 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 4 GB
  • SSD: 50 GB NVMe
BASIC · vn-01Recommended

VPS-05

457.600 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478